From a55b575e8089ee6cab7c5c262a7e6db55d0e34d6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:46:50 +0100 Subject: unslug es: move --- .../global_objects/array/values/index.html | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 files/es/web/javascript/reference/global_objects/array/values/index.html (limited to 'files/es/web/javascript/reference/global_objects/array/values') diff --git a/files/es/web/javascript/reference/global_objects/array/values/index.html b/files/es/web/javascript/reference/global_objects/array/values/index.html new file mode 100644 index 0000000000..dbc76e8634 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/array/values/index.html @@ -0,0 +1,82 @@ +--- +title: Array.prototype.values() +slug: Web/JavaScript/Referencia/Objetos_globales/Array/values +tags: + - Array + - ECMAScript 2015 + - Iterador + - JavaScript + - Prototipo + - metodo +translation_of: Web/JavaScript/Reference/Global_Objects/Array/values +--- +
{{JSRef}}
+ +

El método values() devuelve un nuevo objeto Array Iterator que contiene los valores para cada índice del array.

+ +
var a = ['w', 'y', 'k', 'o', 'p'];
+var iterator = a.values();
+
+console.log(iterator.next().value); // w 
+console.log(iterator.next().value); // y 
+console.log(iterator.next().value); // k 
+console.log(iterator.next().value); // o 
+console.log(iterator.next().value); // p
+
+ +

Sintaxis

+ +
arr.values()
+
+ +

Valor devuelto

+ +

Un nuevo objeto {{jsxref("Array")}} iterator.

+ +

Ejemplos

+ +

Iteración usando un bucle for...of

+ +
var arr = ['w', 'y', 'k', 'o', 'p'];
+var iterador = arr.values();
+
+for (let letra of iterador) {
+  console.log(letra);
+}
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES2015', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ES2015')}}Definición inicial.
{{SpecName('ESDraft', '#sec-array.prototype.values', 'Array.prototype.values')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad con navegadores

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

Vea también

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