Javascript Set delete()

Introduction

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

mySet.delete(value);
  • value - the value to remove from mySet.

It returns true if value was removed from mySet; otherwise false.

const mySet = new Set();// ww  w .j a va  2  s  . co m
console.log(mySet);
mySet.add('foo');
console.log(mySet);
let a = mySet.delete('bar'); 
console.log(a);
console.log(mySet);
a = mySet.delete('foo');
console.log(a);
console.log(mySet);

a = mySet.has('foo');
console.log(a);



PreviousNext

Related