JS Built-ins
WeakMapintermediate

WeakMap β€” non-object key throws

πŸ“– Usage Example
const wm = new WeakMap()
new WeakMap() === new WeakMap()  // β†’ false

Each WeakMap() call creates a distinct new instance.

WeakMap Key Requirement

WeakMap keys must be objects. Passing a primitive throws a TypeError.

Challenge: Verify this throws.

πŸ’‘ Hints (1)
  • β€’ Only objects (and Symbols in modern engines) are valid WeakMap keys.