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 WeakMap
object, but is no longer part of ECMAScript and its implementations.
Syntax
wm.clear();
Examples
Using the clear
method
var wm = new WeakMap(); var obj = {}; wm.set(obj, 'foo'); wm.set(window, 'bar'); wm.has(obj); // true wm.has(window); // true wm.clear(); wm.has(obj) // false wm.has(window) // false
Specifications
Not part of any current specification or draft. This method was part of the ECMAScript 6 draft specification until revision 28 (version of October 14, 2014), but has been removed in later versions of the draft. It will not be part of the final 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.
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 36 — 43 | No | 20 — 46 | 11 | 25 — 30 | 8 — 9 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 36 — 43 | 36 — 43 | No | 20 — 46 | 11 | 25 — 30 | 8 — 9 |