delete Method (Set) (JavaScript)

Removes the specified element from a set.

setObj.delete(value)

setObj

Required. A Set object.

value

Required. The element to remove.

true if the element has been removed.

The following example shows how to add members to a Set and then delete one of them.

var s = new Set();
s.add("Thomas Jefferson");
s.add(1776);
s.add("founding father");
s.delete("founding father");

s.forEach(function (item) {
    document.write(item.toString() + ", ");
});

// Output:
// Thomas Jefferson, 1776,

Supported in the Internet Explorer 11 standards document mode. Also supported in Store apps (Windows 8.1 and Windows Phone 8.1). See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Not supported in Windows 8.

Show:
© 2014 Microsoft