Standard built-ins

Symbol.keyFor()

Try the free JavaScript compiler

Return the registry key for a registered symbol, otherwise undefined; non-symbol arguments throw TypeError. The description is not necessarily the registry key.

Formal Syntax & Structure

javascript syntaxjavascript
Symbol.keyFor(sym)

Parameters & Attributes

NameTypeDescription
symsymbolSymbol to look up.

Return Value

string | undefined

Registered string key, if present.

Working Example

Example Snippetjavascript
console.log(Symbol.keyFor(Symbol.for("k")),Symbol.keyFor(Symbol("k")));
JavaScript Reference