🔺Symbol
JS ⟩ value ⟩ primitive ⟩ 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 (computed) property names.❗
are primitive values, not objects, Symbol() is not a constructor.❗
can't invoke with new❗
Last updated
Was this helpful?