From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../global_objects/array/values/index.html | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 files/it/web/javascript/reference/global_objects/array/values/index.html (limited to 'files/it/web/javascript/reference/global_objects/array/values') diff --git a/files/it/web/javascript/reference/global_objects/array/values/index.html b/files/it/web/javascript/reference/global_objects/array/values/index.html new file mode 100644 index 0000000000..f3019ef144 --- /dev/null +++ b/files/it/web/javascript/reference/global_objects/array/values/index.html @@ -0,0 +1,87 @@ +--- +title: Array.prototype.values() +slug: Web/JavaScript/Reference/Global_Objects/Array/values +translation_of: Web/JavaScript/Reference/Global_Objects/Array/values +--- +
{{JSRef}}
+ +

 

+ +

Il metodo values() restituisce un nuovo oggetto Array Iterator che contiene i valori per ogni indice nell'array.

+ +

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

+ +
var a = ['a', 'b', 'c', 'd', 'e'];
+var iterator = a.values();
+
+console.log(iterator.next().value); // a
+console.log(iterator.next().value); // b
+console.log(iterator.next().value); // c
+console.log(iterator.next().value); // d
+console.log(iterator.next().value); // e
+ +

Sintassi

+ +
arr.values()
+ +

Valore di ritorno

+ +

Un nuovo oggetto iteratore {{jsxref("Array")}}.

+ +

Esempi

+ +

Iterazione utilizzando il  for...of loop

+ +
var arr = ['a', 'b', 'c', 'd', 'e'];
+var iterator = arr.values();
+
+for (let letter of iterator) {
+  console.log(letter);
+}
+
+ +

Array.prototype.values è una implementazionde di default di Array.prototype[Symbol.iterator].

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

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

+ +

Specificazioni

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ES2015')}}Definizione iniziale.
{{SpecName('ESDraft', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ +
+ + +

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

+
+ +

See also

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