`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 Latest Draft (ECMA-262) Set.prototype.clear | 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!

- Desktop
- Mobile

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

## 相关链接

- `Set`
- `Set.prototype.delete()`