JavaScript question detail
What are the differences between WeakSet and Set
The main difference is that references to objects in Set are strong while references to objects in WeakSet are weak. i.e, An object in WeakSet can be garbage collected if there is no other reference to it.
Other differences are:
Setcan store any value whereasWeakSetcan store only collections of objectsWeakSetdoes not have size property unlikeSetWeakSetdoes not have methods such as clear, keys, values, entries, forEach.WeakSetis not iterable.