Web/JavaScript/Reference/Global objects/WeakSet/clear
ObsoleteThis 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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Chrome
No support 36 — 41 |
Edge
No support No |
Firefox
No support 34 — 46 |
IE
No support No |
Opera
No support 23 — 28 |
Safari
No support No |
WebView Android
No support 37 — 41 |
Chrome Android
No support 36 — 41 |
Firefox Android
No support 34 — 46 |
Opera Android
No support 24 — 28 |
Safari iOS
No support No |
Samsung Internet Android
No support 3.0 — 4.0 |
nodejs
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
WeakSet.prototype.clear() by Mozilla Contributors is licensed under CC-BY-SA 2.5.