The delete() method of a Set removes a specified value from the set, if it's in the set.
const months = new Set(['Jan', 'Feb', 'March']);
months.delete('Jan');
console.log(Array.from(months));
// ["Feb", "March"]
// another, more-advanced example
const points = new Set();
points.add({ x: 10, y: 20 }).add({ x: 20, y: 30 });
// Delete any point with `x > 10`.
points.forEach((point) => {
if (point.x > 10) {
points.delete(point);
}
});
console.log(Array.from(points));
// [{ x: 10, y: 20 }]