From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- .../global_objects/set/entries/index.html | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 files/zh-tw/web/javascript/reference/global_objects/set/entries/index.html (limited to 'files/zh-tw/web/javascript/reference/global_objects/set/entries/index.html') diff --git a/files/zh-tw/web/javascript/reference/global_objects/set/entries/index.html b/files/zh-tw/web/javascript/reference/global_objects/set/entries/index.html new file mode 100644 index 0000000000..6bf609afb2 --- /dev/null +++ b/files/zh-tw/web/javascript/reference/global_objects/set/entries/index.html @@ -0,0 +1,78 @@ +--- +title: Set.prototype.entries() +slug: Web/JavaScript/Reference/Global_Objects/Set/entries +tags: + - ECMAScript 2015 + - JavaScript + - 原型 + - 方法 + - 迭代器 + - 集合 +translation_of: Web/JavaScript/Reference/Global_Objects/Set/entries +--- +
{{JSRef}}
+ +
entries() 方法回傳一個 Iterator 物件,其包含著一個由插入順序排序,Set 物件中每個元素的 [value, value] 陣列。儘管對 Set 物件來說沒有像 Map 一樣的 key 概念,為了確保這個 API 運作的與 Map 相似,每個 entry 都有同樣的值同時作為其 keyvalue ,因此回傳的是一個[value, value] 的陣列。
+ +
{{EmbedInteractiveExample("pages/js/set-prototype-entries.html")}}
+ + + +

語法

+ +
mySet.entries()
+ +

回傳值

+ +

一個新的 Iterator 物件,包含著一個由插入順序排序,Set 物件中每個元素的 [value, value] 陣列。

+ +

範例

+ +

使用 entries()

+ +
var mySet = new Set();
+mySet.add('foobar');
+mySet.add(1);
+mySet.add('baz');
+
+var setIter = mySet.entries();
+
+console.log(setIter.next().value); // ["foobar", "foobar"]
+console.log(setIter.next().value); // [1, 1]
+console.log(setIter.next().value); // ["baz", "baz"]
+
+ +

規範

+ + + + + + + + + + + + + + + + + + + +
規範狀態
{{SpecName('ES2015', '#sec-set.prototype.entries', 'Set.prototype.entries')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.entries', 'Set.prototype.entries')}}{{Spec2('ESDraft')}} 
+ +

瀏覽器相容性

+ + + +

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

+ +

另見

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