The JavaScript WeakSet object is the type of collection that allows us to store weakly held objects. Unlike Set, the WeakSet are the collections of objects only. It doesn’t contain the arbitrary values.
Syntax
new WeakSet([iterable])
Parameter
iterable – It represents the iterable object whose elements will be added to a new WeakSet.
Points to remember
- A WeakSet object contains unique objects only.
- In WeakSet, if there is no reference to a stored object, they are targeted to garbage collection.
- In WeakSet, the objects are not enumerable. So, it doesn’t provide any method to get the specified objects.
JavaScript WeakSet Methods
Let’s see the list of JavaScript WeakSet methods with their description.
Leave a Reply