The Javascript WeakSet add()
method appends object to a WeakSet object.
It returns the WeakSet object.
ws.add(value);
Parameters | Optional | Meaning |
---|---|---|
value | Required. | The object to add to the WeakSet. |
Weakset only takes objects as arguments.
var ws = new WeakSet(); console.log(ws);//from ww w . j a v a 2 s . co m ws.add(window); console.log(ws); ws.has(window); console.log(ws); //ws.add(1); error