WeakMap.prototype.get()
The get()
method returns a specified element from a
WeakMap
object.
Syntax
get(key)
Parameters
key
-
Required. The key of the element to return from the
WeakMap
object.
Return value
The element associated with the specified key in the WeakMap
object. If
the key can't be found, undefined
is returned.
Examples
Using the get() method
var wm = new WeakMap();
wm.set(window, 'foo');
wm.get(window); // Returns "foo".
wm.get('baz'); // Returns undefined.
Specifications
Specification |
---|
ECMAScript Language Specification # sec-weakmap.prototype.get |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
get | ChromeFull support36 | EdgeFull support12 | FirefoxFull support6 | Internet ExplorerFull support11 | OperaFull support23 | SafariFull support8 | WebView AndroidFull support37 | Chrome AndroidFull support36 | Firefox for AndroidFull support6 | Opera AndroidFull support24 | Safari on iOSFull support8 | Samsung InternetFull support3.0 | DenoFull support1.0 | Node.jsFull support0.12.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
- User must explicitly enable this feature.
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.