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 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.
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
clear | Chrome No support 36 — 43 | Edge No support No | Firefox No support 20 — 46 | IE Full support 11 | Opera No support 25 — 30 | Safari No support 8 — 9 | WebView Android No support 37 — 43 | Chrome Android No support 36 — 43 | Firefox Android No support 20 — 46 | Opera Android No support 25 — 30 | Safari iOS No support 8 — 9 | Samsung Internet Android No support 3.0 — 4.0 | nodejs No support 0.12 — 4.0.0 |
Legend
- Full support
- Full support
- 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.