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

Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil) . Junte-se a nós e ajude a fazer o trabalho!

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

Etiquetas do documento e colaboradores

 Colaboradores desta página: vaniananthuni, hbloomer, Andrew_Pfeiffer, MKJ, gargsms, fscholz
 Última atualização por: vaniananthuni,