[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/get [Back]  [Original]

WeakMap.prototype.get() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

WeakMap.prototype.get()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

get() WeakMap,

In this article

wm.get(key);

key

. , WeakMap.

undefined, WeakMap.

get

js
var wm = new WeakMap();
wm.set(window, "foo");

wm.get(window); //  "foo".
wm.get("baz"); //  undefined.

Specification
ECMAScript 2027 LanguageSpecification
# sec-weakmap.prototype.get

Firefox-specific notes

  • Prior to SpiderMonkey 38, this method threw a TypeError when the key parameter was not an object. However, the latest ES6 standard specifies to return undefined instead. Furthermore, WeakMap.prototype.get accepted an optional second argument as a fallback value, which is not part of the standard. Both non-standard behaviors are removed in version 38 and higher (Firefox bug 1127827).


Web Proxy Viewer  |  New URL  |  Original Page