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 | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 files/uk/web/javascript/reference/global_objects/array/entries/index.html (limited to 'files/uk/web/javascript/reference/global_objects/array/entries') diff --git a/files/uk/web/javascript/reference/global_objects/array/entries/index.html b/files/uk/web/javascript/reference/global_objects/array/entries/index.html new file mode 100644 index 0000000000..b55d83c2e5 --- /dev/null +++ b/files/uk/web/javascript/reference/global_objects/array/entries/index.html @@ -0,0 +1,96 @@ +--- +title: Array.prototype.entries() +slug: Web/JavaScript/Reference/Global_Objects/Array/entries +tags: + - Array + - ECMAScript6 + - JavaScript + - Ітератор + - Масив + - метод +translation_of: Web/JavaScript/Reference/Global_Objects/Array/entries +--- +
{{JSRef}}
+ +

Метод entries() повертає новий об'єкт ітератора масиву (Array Iterator), який містить пари ключ-значення для кожного індексу в масиві.

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

Синтаксис

+ +
array.entries()
+ +

Значення, яке повертається

+ +

Новий об'єкт ітератора {{jsxref("Array", "масиву")}}.

+ +

Приклади

+ +

Ітерування за індексом та елементом

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

Використання циклу for…of

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

Специфікації

+ + + + + + + + + + + + + + + + + + + +
СпецифікаціяСтатусКоментар
{{SpecName('ES2015', '#sec-array.prototype.entries', 'Array.prototype.entries')}}{{Spec2('ES2015')}}Початкове визначення.
{{SpecName('ESDraft', '#sec-array.prototype.entries', 'Array.prototype.entries')}}{{Spec2('ESDraft')}}
+ +

Сумісність з веб-переглядачами

+ +
+ + +

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

+
+ +

Див. також

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