Favorites

JavaScript Set.prototype.delete() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Set.prototype.delete()
JavaScript Set Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The delete() method removes a value from a Set.

Description

The delete() method removes a value from the set and returns whether it was present. clear() removes every value.

Removing values while looping over the set is safe: values that haven't been visited yet and are removed are simply skipped. To remove every value at once, call clear().

Values are compared with the SameValueZero algorithm, so NaN matches NaN, but two separate objects with the same contents are different values.

Syntax

set.delete(value)

Parameters

  • valueThe value to remove.

Return Value

true if the value was removed, false if it wasn't there.

Example

const s = new Set([1, 2, 3]);
console.log(s.delete(2), s.delete(9));
console.log(s);

Browser Support

The following information will show you the current browser support for the Set.prototype.delete() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee