JS Built-ins
WeakSetaddbeginner

WeakSet.prototype.add() β€” no duplicates

πŸ“– Usage Example
const ws = new WeakSet()
const o = {}
const result = ws.add(o)
result === ws  // β†’ true

add() returns the WeakSet itself for chaining.

WeakSet No Duplicates

Adding the same object twice doesn't create duplicates β€” has() still returns true.

Challenge: Verify adding the same object twice is idempotent.

πŸ’‘ Hints (1)
  • β€’ WeakSet only stores each reference once.