JavaScript Removing a value


Example

To remove a value from a WeakSet, use the .delete() method. This method returns true if the value existed and has been removed, otherwise false.

const obj1 = {},
      obj2 = {};

const weakset = new WeakSet([obj1]);
console.log(weakset.delete(obj1)); // true
console.log(weakset.delete(obj2)); // false