From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/weakmap/get/index.html | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html new file mode 100644 index 0000000000..5dd596c3ff --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html @@ -0,0 +1,120 @@ +--- +title: WeakMap.prototype.get() +slug: Web/JavaScript/Reference/Global_Objects/WeakMap/get +translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/get +--- +
{{JSRef}}
+ +

get() 方法返回  WeakMap 指定的元素。

+ +

语法

+ +
wm.get(key);
+ +

参数

+ +
+
key
+
必须。 想要从 WeakMap 获取的元素的键。
+
+ +

返回值

+ +

返回与指定键相关联的值,如果 WeakMap 对象找不到这个键则返回 undefined

+ +

例子

+ +

使用 get 方法 

+ +
var wm = new WeakMap();
+wm.set(window, "foo");
+
+wm.get(window); // 返回 "foo".
+wm.get("baz");  // 返回 undefined.
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES6', '#sec-weakmap.prototype.get', 'WeakMap.prototype.get')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-weakmap.prototype.get', 'WeakMap.prototype.get')}}{{Spec2('ESDraft')}} 
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support36{{CompatGeckoDesktop("6.0")}}11237.1
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatGeckoMobile("6.0")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Firefox 中的注意事项

+ + + +

相关链接

+ + -- cgit v1.2.3-54-g00ecf