Symbols in ECMAScript 6
Symbols are a new primitive type in ECMAScript 6 [1] . This blog post explains how they work. A new primitive type ECMAScript 6 introduces a new primitive type: symbols. They are tokens that serve as unique IDs. You create symbols via the factory function Symbol() (which is loosely similar to String returning strings if called as a function): let symbol1 = Symbol(); Symbol() has an optional string-valued parameter that lets you give the newly created symbol a description: > let symbol2 = Symbol('symbol2'); > String(symbol2) 'Symbol(symbol2)' Every symbol returned by Symbol() is unique, every symbol has its own identity: > symbol1 === symbol2 false You can see that symbols are primitive if you apply the typeof operator to one of them – it will return a new symbol-specific result: > typeof symbol1 'symbol' Aside: Two quick ideas of mine. If a symbol has no description, JavaScript engines could use the name of the v...