JavaScript WeakSet Object
Syntax
Code
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.
Methods | Description |
---|---|
add() | It adds a new object to the end of WeakSet object. |
delete() | It removes the specified object from the WeakSet object. |
has() | It indicates whether the WeakSet object contains the specified object element. |
Comments