What is the "Symbol" javascript type as mentioned in this ECMAScript 6 draft specification?
To quote the spec:
The Symbol type is the set of all non-String values that may be used as the key of an Object property.
Each possible Symbol values is unique and immutable.
Symbol values have a single observable attribute called [[Private]] whose immutable value is either true or false. A private symbol is a Symbol value whose [[Private]] attribute has the value true.
I thought object keys were strings only, and I'm not alone. To quote this accepted SO answer:
…object keys are always strings…
Could you explain what the symbol type is, and demonstrate its usage. I'm trying to make sense of the spec.
Thanks!