JS Built-ins
Symbolforbeginner

Symbol.for() vs Symbol() β€” not the same

πŸ“– Usage Example
const g = Symbol.for('foo')
const l = Symbol('foo')
g === l   // β†’ false

Symbol.for() returns a globally shared symbol, while Symbol() always creates a new local one.

Symbol.for vs Symbol

Symbol.for('foo') and Symbol('foo') create different symbols β€” one is global, the other is local.

Challenge: Confirm they are not equal.

πŸ’‘ Hints (1)
  • β€’ Symbol.for() registers globally; Symbol() is always a new local symbol.