Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

A Symbol is a primitive data type whose instances are unique and immutable. In some programming languages they are also called atoms.

In JavaScript, Symbol is one of the primitive values and the Symbol object is a wrapper around a Symbol primitive.

Symbol can have an optional description, but for debugging purposes only.

Symbol type is a new feature in EcmaScript 6 (es6) and there is no EcmaScript 5 equivalent for symbol.

Symbol("foo") !== Symbol("foo")
const foo = Symbol()
const bar = Symbol()
typeof foo === "symbol"
typeof bar === "symbol"
let obj = {}
obj[foo] = "foo"
obj[bar] = "bar"
JSON.stringify(obj) // {}
Object.keys(obj) // []
Object.getOwnPropertyNames(obj) // []
Object.getOwnPropertySymbols(obj) // [ foo, bar ]

Learn more

General knowledge

Document Tags and Contributors

 Contributors to this page: vaniananthuni, hbloomer, Andrew_Pfeiffer, MKJ, gargsms, fscholz
 Last updated by: vaniananthuni,