[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Array/values [Back]  [Original]

Array.prototype.values() - JavaScript | MDN

Esta pgina foi traduzida do ingls pela comunidade. Saiba mais e junte-se comunidade MDN Web Docs.

View in English Always switch to English

Array.prototype.values()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since maio de 2018.

O mtodo values() retorna um novo objeto de Array Iterator que contm os valores para cada ndice no array.

In this article

Sintaxe

arr.values()

Exemplos

Iterao usando for...of loop

js
var arr = ["w", "y", "k", "o", "p"];
var eArr = arr.values();
// seu navegador deve suportar for..of loop
// e deixar variveis let-scoped no for loops
for (let letter of eArr) {
  console.log(letter);
}

Iterao alternativa

js
var arr = ["w", "y", "k", "o", "p"];
var eArr = arr.values();
console.log(eArr.next().value); // w
console.log(eArr.next().value); // y
console.log(eArr.next().value); // k
console.log(eArr.next().value); // o
console.log(eArr.next().value); // p

Especificaes

Specification
ECMAScript 2027 LanguageSpecification
# sec-array.prototype.values

Compatibilidade com navegadores

Notas especficas do Firefox

Ver tambm


Web Proxy Viewer  |  New URL  |  Original Page