HomeToolsAbout a20k

Symbol

Symbol

A symbol is a unique and immutable data type and may be used as an identifier for object properties

Why use Symbol

See Inversify page Why use symbol over string for concrete example.

Link

Symbol.keyFor()

The Symbol.keyFor() static method retrieves a shared symbol key from the global symbol registry for the given symbol

// Global symbol const globalSym = Symbol.for('foo'); console.log(Symbol.keyFor(globalSym)); // "foo" // Local symbol const localSym = Symbol(); console.log(Symbol.keyFor(localSym)); // undefined
© VincentVanKoh