WeakMap.prototype.get()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
get() ë©ìëë WeakMap ê°ì²´ìì í¹ì ìì를 ë°íí©ëë¤.
ìëí´ ë³´ê¸°
const weakmap1 = new WeakMap();
const object1 = {};
const object2 = {};
weakmap1.set(object1, 42);
console.log(weakmap1.get(object1));
// Expected output: 42
console.log(weakmap1.get(object2));
// Expected output: undefined
구문
js
get(key);
매ê°ë³ì
key-
íìë¡ ì구ëë©°,
WeakMapê°ì²´ìì ë°íí ììì í¤ì ëë¤.
ë°í ê°
WeakMap ê°ì²´ì í¹ì í¤ì ì°ê²°ë ììì
ëë¤. í¤ë¥¼ ì°¾ì ì ìì¼ë©´ undefinedê° ë°íë©ëë¤.
ìì
>get() ë©ìë ì¬ì©í기
js
const wm = new WeakMap();
wm.set(window, "foo");
wm.get(window); // "foo" ë°í.
wm.get("baz"); // undefined ë°í.
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-weakmap.prototype.get> |