MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-survey

I volontari di MDN non hanno ancora tradotto questo articolo in Italiano. Unisciti a noi e traducilo tu stesso.
Puoi anche consultare l’articolo in English (US).

The values() method returns a new Array Iterator object that contains the values for each index in the 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

Syntax

arr.values()

Return value

A new Array iterator object.

Examples

Iteration using for...of loop

var arr = ['w', 'y', 'k', 'o', 'p'];
var iterator = arr.values();

for (let letter of iterator) {
  console.log(letter);
}

Specifications

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Array.prototype.values' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Array.prototype.values' in that specification.
Draft  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support66 Yes60 No539
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support6666 Yes60539 ?

See also

Tag del documento e collaboratori

 Hanno collaborato alla realizzazione di questa pagina: vitaly-zdanevich, wbamberg, fscholz, concavelenz, erikadoyle, kdex, David_Gilbertson, eduardoboucas, malyw, yihongang, riyajk, coin723, yan, arai, Mingun, P0lip
 Ultima modifica di: vitaly-zdanevich,