Last updated 2 years ago
Was this helpful?
⟩ ⟩ ⟩ symbol
returns a primitive value that's guaranteed to be unique.
const unique = Symbol() // ⭐️ not `new Symbol()`❗️ let obj = { [unique]: <value>, // symbol used as a computed property name };
Symbols
only used as .
are values, not objects, Symbol() is not a .
can't invoke with
Symbol.iterator - name of a required method for iterables.
Symbols can be used as .
object literal
JavaScript: The Definitive Guide ⟩
3.6 Symbols
6.10.3 Symbols as Property Names