Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript WeakSet Complete Reference

Improve Article
Save Article
  • Last Updated : 22 Mar, 2023
Improve Article
Save Article

JavaScript WeakSet is used to store a collection of objects. It adapts the same properties as that of a set i.e. does not store duplicates. The major difference between WeakSet and a set is that a WeakSet is a collection of objects and not values of some particular type.



Example: In this example we will use the JavaScript weakSet() method.


    // Constructing a weakSet() object
    const A = new WeakSet();
    // Constructing new objects
    const object1 = {};
    // Adding the new object to the weakSet
    // Checking whether the new object is present
    // in the weakSet or not





The complete list of JavaScript WeakSet is listed below:

JavaScript WeakSet Constructor: In JavaScript, a constructor gets called when an object is created using the new keyword.


weakSet()A constructor gets called when an object is created using the new keyword.

JavaScript WeakSet Properties: A JavaScript property is a member of an object that associates a key with a value. There is no static property in the weakSet only instance property.

Instance PropertyDescription

constrcutorReturn the wekaMap constructor function for the object.

JavaScript WeakSet Method: JavaScript methods are actions that can be performed on objects.

  • Instance Method: If the method is called on an instance of a number then it is called an instance method.

Instance Method


add()Add an object at the end of an object WeakSet.
delete()Delete a specific element from a weakSet object.
has()Return a boolean value indicating whether an object is present in a weakSet or not. that
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!