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

Phương thức entries() trả về một mảng đối tượng Array Iterator chứa cặp key/value cho mỗi chỉ mục trong mảng.

+ +
{{EmbedInteractiveExample("pages/js/array-entries.html")}}
+ + + +

Syntax

+ +
array.entries()
+ +

Return value

+ +

Một {{jsxref("Array")}} đối tượng iterator.

+ +

Examples

+ +

Iterating with index and element

+ +
const a = ['a', 'b', 'c'];
+
+for (const [index, element] of a.entries())
+  console.log(index, element);
+
+// 0 'a'
+// 1 'b'
+// 2 'c'
+
+ +

Using a for…of loop

+ +
var a = ['a', 'b', 'c'];
+var iterator = a.entries();
+
+for (let e of iterator) {
+  console.log(e);
+}
+// [0, 'a']
+// [1, 'b']
+// [2, 'c']
+
+ +

Specifications

+ + + + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-array.prototype.entries', 'Array.prototype.entries')}}
+ +

Browser compatibility

+ +
+ + +

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

+
+ +

See also

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