Symbol datatype in JavaScript

Symbols are new primitive type added in ECMAScript 2015. Symbols do not have a literal syntax, they have a Symbol() function that can be used to create them.

Symbols are unique. Each new symbol has a new, unique value.
Symbol() === Symbol() // false

1. Symbols may be used as unique property keys. They prevent name clashes.
2. They may be used as constants representing concepts.
const CATEGORY_PHONES = Symbol(‘phones’);

Leave a Reply