We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

delete() 方法可以从一个 Set 对象中删除指定的元素。

语法

mySet.delete(value);

参数

value
将要删除的元素

返回值

成功删除返回 true,否则返回 false。

示例

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

mySet.delete("bar"); // 返回 false,不包含 "bar" 这个元素
mySet.delete("foo"); // 返回 true,删除成功

mySet.has("foo");    // 返回 false,"bar" 已经成功删除

规范

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
Set.prototype.delete
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
Set.prototype.delete
Draft  

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 38 13.0 (13.0) 11 25 7.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 38 13.0 (13.0) 未实现 未实现 8

相关链接

文档标签和贡献者

此页面的贡献者: Ende93, ziyunfei
最后编辑者: Ende93,