The Javascript WeakSet has()
method checks whether an object exists in a WeakSet or not.
It returns a boolean value.
ws.has(value);
Parameters | Optional | Meaning |
---|---|---|
value | not | The object to test. |
Using the has method
var ws = new WeakSet(); var obj = {};//from w w w .jav a 2 s . c o m ws.add(window); let a = mySet.has(window); // returns true console.log(a); a = mySet.has(obj); // returns false console.log(a);