Tutorial by Examples

Symbol is a new primitive type in ES6. Symbols are used mainly as property keys, and one of its main characteristics is that they are unique, even if they have the same description. This means they will never have a name clash with any other property key that is a symbol or string. const MY_PROP_KE...
Unlike most other JavaScript objects, symbols are not automatically converted into a string when performing concatenation. let apple = Symbol('Apple') + ''; // throws TypeError! Instead, they have to be explicitly converted into a string when necessary, (for example, to get a textual description...
The Symbol.for method allows you to register and look up global symbols by name. The first time it is called with a given key, it creates a new symbol and adds it to the registry. let a = Symbol.for('A'); The next time you call Symbol.for('A'), the same symbol will be returned instead of a new o...

Page 1 of 1