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

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support36 — 43 No34 — 46 No25 — 30 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support36 — 4336 — 43 No34 — 4625 — 30 No Yes

See also

Document Tags and Contributors

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