Symbol.for

Returns a Symbol object from the global symbol registry matching the given key if found. Otherwise, returns a new symbol with this key.

Syntax

Symbol.for(key)

Parameters

Return value

A Symbol object.

Examples

Symbol.for("peace") === Symbol.for("peace")
true