Javascript WeakSet delete()

Introduction

The Javascript WeakSet delete() method removes the element from a WeakSet object.

ws.delete(value);
ParametersOptionalMeaning
value Not The object to be removed from the WeakSet object.

It returns true if an element has been removed successfully.

It returns false if the key is not found in the WeakMap or the key is not an object.

var ws = new WeakSet();
var obj = {};//from w  w w  . ja  v a2  s . com

ws.add(window);

let a = ws.delete(obj);
console.log(a);
a = ws.delete(window);
console.log(a);
a = ws.has(window);
console.log(a);



PreviousNext

Related