Javatpoint Logo
Javatpoint Logo

JavaScript WeakSet Object

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.



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.

Next TopicJavaScript WeakMap

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA