Standard built-ins

Symbol.for()

Try the free JavaScript compiler

Converts the key to a string and retrieves the corresponding global registry symbol, creating it if necessary. Calls with the same registry key return the same symbol. This is not a privacy mechanism or a guarantee that arbitrary fresh symbols are registered.

Formal Syntax & Structure

javascript syntaxjavascript
Symbol.for(key)

Parameters & Attributes

NameTypeDescription
keyanyRegistry key converted to a string.

Return Value

symbol

Registered symbol for the string key.

Working Example

Example Snippetjavascript
console.log(Symbol.for("record") === Symbol.for("record"));
JavaScript Reference