JS Built-ins
WeakSetaddbeginner

WeakSet.prototype.add() β€” returns WeakSet

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

Adding the same object twice has no effect; WeakSet stores unique references.

WeakSet add() Return Value

ws.add(obj) returns the WeakSet itself.

Challenge: Verify add returns the WeakSet.

πŸ’‘ Hints (1)
  • β€’ Like Set.add(), WeakSet.add() returns the set itself.