ES6 - Set Method delete()


Advertisements

This function is used to delete a specific element from the Set.

Syntax

The syntax mentioned below is for delete, where, value is the value to delete from the Set.

set_name.delete(value)

Example

<script>
   let names= new Set(['A','B','C','D']);
   console.log(names)
   names.delete('A')
   console.log(names)
</script>

The output of the above code is as follows −

{"A", "B", "C", "D"}
{"B", "C", "D"}
Advertisements