JavaScript weakSet has() Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report JavaScript weakSet.has() method is used to return a boolean value indicating whether an object is present in a weakSet or not. The WeakSet object lets you store weakly held objects in a collection. Syntax: weakSet.has(value); Parameters: This method accepts a single parameter value. value: This value is going to be checked whether it is present in the weakSet object or not. Return Values: It returns a boolean value true if the element is present otherwise it returns false. Below are examples of weakSet.has() method: Example 1: javascript function gfg() { const A = new WeakSet(); const object = {}; A.add(object); console.log(A.has(object)); } gfg(); Output: Here output is true because the object "object" is present in the WeakSet() object. true Example 2: 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)); Output: Here output is true because the object "object1" is present in the WeakSet() object. true Example 3: javascript // Constructing a weakSet() object const A = new WeakSet(); // Constructing new objects const object1 = {}; // Checking whether the new object is present // in the weakSet or not console.log(A.has(object1)); Output: Here the output is false because the object "object1" is not present in the WeakSet() object. false Supported Browsers: Google Chrome 36 and aboveFirefox 34 and aboveApple Safari 9 and aboveOpera 23 and aboveEdge 12 and above We have a complete list of Javascript weakSet methods, to check those please go through this JavaScript WeakSet Complete Reference article. Comment More infoAdvertise with us S ShivamKD Follow Improve Article Tags : JavaScript Web Technologies JavaScript-WeakSet JavaScript-Methods Similar Reads JavaScript WeakSet() Constructor JavaScript WeakSet Constructor is used to create a weakset that is similar to the set as it does not contain duplicate objects. It is different from the set as it stores a collection of weakly held objects instead of an object of a particular type. We can only create a WeakSet with the new keyword o 2 min read JavaScript WeakSet constructor Property JavaScript WeakSet constructor property is used to return the WeakSet constructor function for the object. The function returned by this property is just the reference, not the actual WeakSet. It is an object property of JavaScript and can be used with Strings, Numbers, etc. Syntax: weakset.construc 1 min read JavaScript weakSet add() Method Javascript weakSet.add() is used to add an object at the end of the object WeakSet. The WeakSet object lets you store weakly held objects in a collection. Syntax: weakSet.add(A);Parameters: This method accepts a single parameter value. value: This value will be added to the weakset object. Return Va 2 min read JavaScript weakSet delete() Method JavaScript weakSet.delete() method is used to delete a specific element from a weakSet object. The WeakSet object lets you store weakly held objects in a collection. Syntax: weakSet.delete(value); Parameters: This method accepts a single parameter value. value: This value will be deleted from the we 2 min read JavaScript weakSet has() Method JavaScript weakSet.has() method is used to return a boolean value indicating whether an object is present in a weakSet or not. The WeakSet object lets you store weakly held objects in a collection. Syntax: weakSet.has(value); Parameters: This method accepts a single parameter value. value: This valu 2 min read Like