Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Set.prototype.clear()

clear() 方法用来清空一个 Set 对象中的所有元素。

语法

mySet.clear();

返回值

undefined.

示例

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

mySet.size;       // 2
mySet.has("foo"); // true

mySet.clear();

mySet.size;       // 0
mySet.has("bar")  // false

规范

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

浏览器兼容性

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

相关链接

文档标签和贡献者

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