0Pricing
JavaScript Academy · Lesson

Creating Unique Symbols

Generate guaranteed-unique values.

What Is a Symbol

A Symbol is a primitive type introduced in modern JavaScript. Every symbol is unique, even if two symbols share the same description.

const s = Symbol()
console.log(typeof s)

Creating a Symbol

You create a symbol by calling the Symbol function. It is not a constructor, so you never use new with it.

const id = Symbol()
console.log(typeof id)

All lessons in this course

  1. Creating Unique Symbols
  2. Symbols as Object Keys
  3. The Global Symbol Registry
  4. Well-Known Symbols
← Back to JavaScript Academy