JavaScript Code

JavaScript Set delete()


Set delete() method

set delete() method is used to delete a value from the set

mySet.delete();
  • mySet is a set object
  • delete is method name

the delete() method returns a boolean value of true, if the specified value is present and removed, or false if the specified value is not present

Examples

1. delete the value 'e' of the vowels set

const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
console.log('vowels : ' + [...vowels]);
vowels.delete('e');
console.log('vowels : ' + [...vowels]);

Copyright @2022