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

Syntax

ws.clear();

Examples

Using the clear method

var ws = new WeakSet();

ws.add(window);
ws.has(window);  // true

ws.clear();

ws.has(window); // false

Specifications

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 AndroidIE mobileOpera AndroidiOS Safari
Basic support36 — 4336 — 43 No34 — 46 No25 — 30 No

See also

Document Tags and Contributors

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