WeakMap

A WeakMap is a collection of key/value pairs whose keys must be objects or non-registered symbols, with values of any arbitrary JavaScript type, and which does not create strong references to its keys. That is, an object's presence as a key in a WeakMap does not prevent the object from being garbage collected. Once an object used as a key has been collected, its corresponding values in any WeakMap become candidates for garbage collection as well — as long as they aren't strongly referred to elsewhere. The only primitive type that can be used as a WeakMap key is symbol — more specifically, non-registered symbols — because non-registered symbols are guaranteed to be unique and cannot be re-created.

Read More at MDN DocsView Spec

Safe to Use

WeakMap is considered safe to use.

It’s supported by 94% of global browsers.

Browsers

ChromeJul 16, 2014v36.0.0
26%100%
100% of Chrome users are running a supported version.
SafariOct 16, 2014v8.0.0
5%100%
100% of Safari users are running a supported version.
EdgeJul 28, 2015v12.0.0
5%100%
100% of Edge users are running a supported version.
FirefoxAug 16, 2011v6.0.0
3%100%
100% of Firefox users are running a supported version.

Servers

Node.jsFeb 6, 2015v0.12.0
Node.js supports this feature.
DenoMay 4, 2020v1.0.0
Deno supports this feature.

Version Breakdown

 
Agent
Support
Adoption
Chrome
Jul 16, 2014 v36.0.0
26%100%
100% of Chrome users are running a supported version.
Jul 16, 2014 – Latest
v36.0.0+
26%100%

Full Support

Chrome Android
Jul 16, 2014 v36.0.0
36%100%
100% of Chrome Android users are running a supported version.
Jul 16, 2014 – Latest
v36.0.0+
36%100%

Full Support

Deno
May 4, 2020 v1.0.0
Deno supports this feature.
May 4, 2020 – Latest
v1.0.0+

Full Support

Edge
Jul 28, 2015 v12.0.0
5%100%
100% of Edge users are running a supported version.
Jul 28, 2015 – Latest
v12.0.0+
5%100%

Full Support

Firefox
Aug 16, 2011 v6.0.0
3%100%
100% of Firefox users are running a supported version.
Aug 16, 2011 – Latest
v6.0.0+
3%100%

Full Support

Firefox for Android
Aug 16, 2011 v6.0.0
Firefox for Android supports this feature.
Aug 16, 2011 – Latest
v6.0.0+

Full Support

Internet Explorer
Oct 17, 2013 v11.0.0
0%83%
There are no users of Internet Explorer running a supported version.
Oct 17, 2013 – Latest
v11.0.0+
0%83%

Full Support

Node.js
Feb 6, 2015 v0.12.0
Node.js supports this feature.
Feb 6, 2015 – Latest
v0.12.0+

Full Support

Mar 11, 2013 – Latest
v0.10.0+

This feature is behind the --harmony runtime_flag

 
Quest Browser
Unknown v5.0.0
Quest Browser supports this feature.
Unknown
v5.0.0+

Full Support

Opera
Jul 22, 2014 v23.0.0
1%100%
100% of Opera users are running a supported version.
Jul 22, 2014 – Latest
v23.0.0+
1%100%

Full Support

Opera Android
Sep 10, 2014 v24.0.0
Opera Android supports this feature.
Sep 10, 2014 – Latest
v24.0.0+

Full Support

Safari
Oct 16, 2014 v8.0.0
5%100%
100% of Safari users are running a supported version.
Oct 16, 2014 – Latest
v8.0.0+
5%100%

Full Support

Safari on iOS
Sep 17, 2014 v8.0.0
16%100%
There are no users of Safari on iOS running a supported version.
Sep 17, 2014 – Latest
v8.0.0+
16%100%

Full Support

Samsung Internet
Apr 10, 2015 v3.0.0
2%97%
There are no users of Samsung Internet running a supported version.
Apr 10, 2015 – Latest
v3.0.0+
2%97%

Full Support

WebView Android
Sep 3, 2014 v37.0.0
WebView Android supports this feature.
Sep 3, 2014 – Latest
v37.0.0+

Full Support

See Also

Contribute