Standard built-ins
Symbol.keyFor()
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
| Name | Type | Description |
|---|---|---|
| sym | symbol | Symbol 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")));