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 WeakSet object, but is no longer part of ECMAScript and its implementations.




Using the clear method

var ws = new WeakSet();

ws.has(window);  // true


ws.has(window); // false


Not part of any current specification or draft. The method was planned for inclusion in ECMAScript 6, but dropped from the draft specification in revision 28 (October 14, 2014). Browser support for the feature was subsequently removed, and it never became part of the final standard.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Basic support
Chrome No support 36 — 43Edge No support NoFirefox No support 34 — 46IE No support NoOpera No support 25 — 30Safari No support NoWebView Android No support 37 — 43Chrome Android No support 36 — 43Edge Mobile No support NoFirefox Android No support 34 — 46Opera Android No support 25 — 30Safari iOS No support NoSamsung Internet Android Full support Yesnodejs No support No


Full support  
Full support
No support  
No support
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

See also

Document Tags and Contributors

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