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

WeakMap.prototype.clear()

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

Obsolete
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.

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

Syntax

wm.clear();

Examples

Using the clear method

var wm = new WeakMap();
var obj = {};

wm.set(obj, "foo");
wm.set(window, "bar");

wm.has(obj); // true
wm.has(window); // true

wm.clear();

wm.has(obj)  // false
wm.has(window)  // false

Specifications

Not part of any current specification or draft. This method was part of the ECMAScript 6 draft specification until revision 28 (version of October 14, 2014), but has been removed in later versions of the draft. It will not be part of the final standard.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 36 No support [1] 11 23 7.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support [1] No support No support 8

[1] The clear() method has been supported from version 20 until version 45 (including).

See also

文档标签和贡献者

 此页面的贡献者: fscholz, claudepache, realityking
 最后编辑者: fscholz,