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/map/entries/index.html | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/map/entries/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/map/entries') diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/entries/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/entries/index.html new file mode 100644 index 0000000000..f97881755e --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/map/entries/index.html @@ -0,0 +1,72 @@ +--- +title: Map.prototype.entries() +slug: Web/JavaScript/Reference/Global_Objects/Map/entries +tags: + - Map +translation_of: Web/JavaScript/Reference/Global_Objects/Map/entries +--- +
{{JSRef}}
+ +

entries() 方法返回一个新的包含 [key, value] 对的 Iterator 对象,返回的迭代器的迭代顺序与 Map 对象的插入顺序相同。

+ +

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

+ +

语法

+ +
myMap.entries()
+
+ +

返回值

+ +

一个新的 {{jsxref("Map")}} 迭代器对象.

+ +

示例

+ +

entries()的使用

+ +
var myMap = new Map();
+myMap.set("0", "foo");
+myMap.set(1, "bar");
+myMap.set({}, "baz");
+
+var mapIter = myMap.entries();
+
+console.log(mapIter.next().value); // ["0", "foo"]
+console.log(mapIter.next().value); // [1, "bar"]
+console.log(mapIter.next().value); // [Object, "baz"]
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ESDraft', '#sec-map.prototype.entries', 'Map.prototype.entries')}}{{Spec2('ESDraft')}}
{{SpecName('ES2015', '#sec-map.prototype.entries', 'Map.prototype.entries')}}{{Spec2('ES2015')}}Initial definition.
+ +

浏览器兼容性

+ +

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

+ +

相关链接

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