From 7267c8c97a1e4d170a0a68e34bc0b3e029f465c7 Mon Sep 17 00:00:00 2001 From: MDN Date: Sat, 17 Jul 2021 00:35:32 +0000 Subject: [CRON] sync translated content --- .../reference/global_objects/map/set/index.html | 97 ---------------------- 1 file changed, 97 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 ae2ff00036..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/map/set/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Map.prototype.set() -slug: Web/JavaScript/Reference/Global_Objects/Map/set -translation_of: Web/JavaScript/Reference/Global_Objects/Map/set -tags: - - ECMAScript 2015 - - JavaScript - - Map - - Method - - Prototype - - Reference -browser-compat: javascript.builtins.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