[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Set/delete [Back]  [Original]

Set.prototype.delete() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Set.prototype.delete()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

delete() Set.

In this article

const set1 = new Set();
set1.add({ x: 10, y: 20 }).add({ x: 20, y: 30 });

// Delete any point with `x > 10`.
set1.forEach((point) => {
  if (point.x > 10) {
    set1.delete(point);
  }
});

console.log(set1.size);
// Expected output: 1

mySet.delete(value);

value

. Set.

true, Set, false.

delete

js
var mySet = new Set();
mySet.add("foo");

mySet.delete("bar"); //  false.   "bar"  .
mySet.delete("foo"); //  true.   .

mySet.has("foo"); //  false.  "foo"   .

Object Set.

js
var setObj = new Set(); //   Set.

setObj.add({ x: 10, y: 20 }); //    .

setObj.add({ x: 20, y: 30 }); //    .

//   point  `x > 10`.
setObj.forEach(function (point) {
  if (point.x > 10) {
    setObj.delete(point);
  }
});

Specification
ECMAScript 2027 LanguageSpecification
# sec-set.prototype.delete


Web Proxy Viewer  |  New URL  |  Original Page