WeakSet.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 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 standard.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
clear
DeprecatedNon-standard
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 — 43Firefox Android No support 34 — 46Opera Android No support 25 — 30Safari iOS No support NoSamsung Internet Android No support 3.0 — 4.0nodejs No support No

Legend

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