From 52ccdf1f0a1cee3f0659ac78e81c79dae152399b Mon Sep 17 00:00:00 2001 From: MDN Date: Wed, 23 Jun 2021 00:34:06 +0000 Subject: [CRON] sync translated content --- .../reference/global_objects/map/set/index.html | 96 ---------------------- 1 file changed, 96 deletions(-) delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/map/set/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/map/set/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/set/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/set/index.html deleted file mode 100644 index 0bdd4579ae..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/map/set/index.html +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: Map.prototype.set() -slug: Web/JavaScript/Reference/Global_Objects/Map/set -tags: - - ECMAScript6 - - JavaScript - - Map - - Method - - Prototype - - 方法 -translation_of: Web/JavaScript/Reference/Global_Objects/Map/set ---- -

{{JSRef}}

- -

set() 方法为 Map 对象添加或更新一个指定了键(key)和值(value)的(新)键值对。

- -
{{EmbedInteractiveExample("pages/js/map-prototype-set.html")}}
- - - -

语法

- -
myMap.set(key, value);
- -

参数

- -
-
key
-
要添加至相应 Map 对象的元素的键。
-
value
-
要添加至相应 Map 对象的元素的值。
-
- -

返回值

- -

Map 对象

- -

示例

- -

使用 set 方法

- -
var myMap = new Map();
-
-// 将一个新元素添加到 Map 对象
-myMap.set("bar", "foo");
-myMap.set(1, "foobar");
-
-// 在Map对象中更新某个元素的值
-myMap.set("bar", "baz");
-
- -

链式使用 set 方法

- -

因为 Set() 方法返回 Map 对象本身,所以你可以像下面这样链式调用它:

- -
// Add new elements to the map with chaining.
-myMap.set('bar', 'foo')
-     .set(1, 'foobar')
-     .set(2, 'baz');
-
- -

规范

- - - - - - - - - - - - - - - - - - - -
规范状态备注
{{SpecName('ES2015', '#sec-map.prototype.set', 'Map.prototype.set')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-map.prototype.set', 'Map.prototype.set')}}{{Spec2('ESDraft')}}
- -

浏览器兼容性

- - - -

{{Compat("javascript.builtins.Map.set")}}

- -

参见

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