Array.prototype.values()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2018.
El método values()
devuelve un nuevo objeto Array Iterator
que contiene los valores para cada índice del array.
js
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 Array
iterator.
Ejemplos
Iteración usando un bucle for...of
js
var arr = ["w", "y", "k", "o", "p"];
var iterador = arr.values();
for (let letra of iterador) {
console.log(letra);
}
Especificaciones
Specification |
---|
ECMAScript® 2025 Language Specification # sec-array.prototype.values |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
values |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.