过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

clear() method used to remove all elements from a WeakSet object, but is no longer part of ECMAScript and its implementations.

句法

ws.clear();
					

范例

使用 clear 方法

var ws = new WeakSet();
ws.add(window);
ws.has(window);  // true
ws.clear();
ws.has(window); // false
					

规范

Not part of any standard.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
clear 弃用 非标 Chrome 36 — 43 Edge No Firefox 34 — 46 IE No Opera 25 — 30 Safari No WebView Android 37 — 43 Chrome Android 36 — 43 Firefox Android 34 — 46 Opera Android 25 — 30 Safari iOS No Samsung Internet Android 3.0 — 4.0 nodejs No

图例

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: