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