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

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

+ +

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

+ +
var a = ['a', 'б', 'в', 'г', 'ґ'];
+var iterator = a.values();
+
+console.log(iterator.next().value); // а
+console.log(iterator.next().value); // б
+console.log(iterator.next().value); // в
+console.log(iterator.next().value); // г
+console.log(iterator.next().value); // ґ
+ +

Синтаксис

+ +
arr.values()
+ +

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

+ +

Новий об'єкт ітератора масиву.

+ +

Приклади

+ +

Перебір за допомогою циклу for...of

+ +
var arr = ['а', 'б', 'в', 'г', 'ґ'];
+var iterator = arr.values();
+
+for (let letter of iterator) {
+  console.log(letter);
+}
+
+ +

Array.prototype.values є реалізацією за замовчуванням для Array.prototype[Symbol.iterator].

+ +
Array.prototype.values === Array.prototype[Symbol.iterator]      //true
+ +

TODO: please write about why we need it, use cases.

+ +

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

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

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

+ +
+ + +

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

+
+ +

Див. також

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