weakSet vs Set
The main differences to the
Setobject are:
WeakSets are collections of objects and symbols only. They cannot contain arbitrary values of any type, asSets can.The
WeakSetis weak, meaning references to objects in aWeakSetare held weakly. If no other references to a value stored in theWeakSetexist, those values can be garbage collected.Note: This also means that there is no list of current values stored in the collection.
WeakSetsare not enumerable.Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet