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.




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.has(obj)  // false
wm.has(window)  // false


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

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic Support36 — 43 No20 — 461125 — 307.1 — 9
FeatureAndroidChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic Support36 — 4336 — 43 No20 — 461125 — 308 — 9

See also

Document Tags and Contributors

 Contributors to this page: fscholz, nmve, claudepache, realityking
 Last updated by: fscholz,