JavaScript WeakSet Reference Last Updated : 23 Jul, 2025 Suggest changes Share Like Article Like Report 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.Syntax:weakSet.function();Example: In this example, we will use the JavaScript weakSet() method. JavaScript // Constructing a weakSet() object const A = new WeakSet(); // Constructing new objects const object1 = {}; // Adding the new object to the weakSet A.add(object1); // Checking whether the new object is present // in the weakSet or not console.log(A.has(object1)); Outputtrue 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.ConstructorDescriptionweakSet()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 Properties: An instance property is a property that has a new copy for every new instance of the class.Instance PropertyDescriptionconstructorReturn 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 WeakSet then it is called an instance method of WeakSet.Instance MethodDescriptionadd()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 K kartik Follow Article Tags : JavaScript Web Technologies JavaScript-WeakSet Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like