Favorites

JavaScript Symbol Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Symbol
JavaScript Fundamental · FunctionThis object is supported by all modern browsers.
Updated 28th November 2026

Symbol creates unique values that can be used as property keys that never clash with other keys. Built-in symbols such as Symbol.iterator let you customize how objects behave.

Description

A Symbol is a primitive value that is guaranteed to be unique. Every call to Symbol() returns a new symbol, even with the same description, so symbols make good property keys when you need to add a property that can't collide with anything else. Symbol-keyed properties are skipped by for...in, Object.keys() and JSON.stringify().

Symbol.for(key) returns a shared symbol from a global registry, the same one each time for the same key. JavaScript also has well-known symbols, such as Symbol.iterator, Symbol.asyncIterator and Symbol.toPrimitive, which objects can define to plug into language features like for...of. Symbol can't be used with new.

Symbols also make it possible to add metadata to objects you don't own without risk of clashing with their existing or future properties. Object.getOwnPropertySymbols() and Reflect.ownKeys() list symbol keys, so they aren't truly private; use #private class fields for real privacy. A symbol's description property returns the text it was created with, which is helpful when debugging.

Syntax

Symbol()
Symbol(description)
Symbol.for(key)

Static properties

NameDescription
Symbol.iteratorSymbol.iterator is the symbol used to make an object iterable.

Example

const id = Symbol('id');
const user = { name: 'Sam', [id]: 123 };

console.log(user[id]);
console.log(Object.keys(user));          // symbol is hidden
console.log(Symbol('a') === Symbol('a'));
console.log(Symbol.for('app') === Symbol.for('app'));
console.log(id.description);

Browser Support

The following information will show you the current browser support for the Symbol object. Hover over a browser icon to see the version that first introduced support for this object.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee