JS Built-ins
WeakMapsetbeginner

WeakMap.prototype.set() β€” overwrite value

πŸ“– Usage Example
const wm = new WeakMap()
const k = {id: 1}
wm.set(k, {data: true})

Values in a WeakMap can be any type, including objects.

WeakMap set() Overwrite

Calling set(key, newValue) overwrites the previous value.

Challenge: Verify overwriting.

πŸ’‘ Hints (1)
  • β€’ Each set() call replaces the previous value for the same key.