JavaScript WeakSet Adding a value


Example

To add a value to a WeakSet, use the .add() method. This method is chainable.

const obj1 = {},
      obj2 = {};

const weakset = new WeakSet();
weakset.add(obj1).add(obj2);