--- title: WeakMap.prototype.get() slug: Web/JavaScript/Reference/Global_Objects/WeakMap/get translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/get ---
Метод get()
возвращает элемент из объекта WeakMap,
wm.get(key);
Возвращает элемент по указанному ключу или undefined, если ключ не может быть найден в объекте WeakMap.
var wm = new WeakMap(); wm.set(window, "foo"); wm.get(window); // Возвращает "foo". wm.get("baz"); // Возвращает undefined.
Specification | Status | Comment |
---|---|---|
{{SpecName('ES6', '#sec-weakmap.prototype.get', 'WeakMap.prototype.get')}} | {{Spec2('ES6')}} | Изначальное определение. |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 36 | {{CompatGeckoDesktop("6.0")}} | 11 | 23 | 7.1 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatGeckoMobile("6.0")}} | {{CompatNo}} | {{CompatNo}} | 8 |
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 ({{bug(1127827)}}).