Set.prototype.delete()
Removes a value from a Set.
Syntax
set.delete(value)
Returns
boolean — `true` if the value was present and removed, otherwise `false`.
Examples
const s = new Set([1, 2, 3]);
console.log(s.delete(2));
console.log([...s]);
Output
true
[ 1, 3 ]
const s = new Set();
console.log(s.delete(99));
Output
false
Notes
- Returns whether anything was actually removed.
- Use `set.clear()` to remove all values at once.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 38 |
| firefox | 13 |
| safari | 8 |
| edge | 12 |
| node | 0.12 |