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
arr.values()
A new Array
iterator object.
for...of
loopvar arr = ['w', 'y', 'k', 'o', 'p']; var iterator = arr.values(); for (let letter of iterator) { console.log(letter); }
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 |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No | Yes | No1 | No | No | 9 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|---|---|
Basic support | No | No | Yes | No | No | No | ? |
1. Available in Firefox Nightly only due to compatibility issues.
Array.prototype.keys()
Array.prototype.entries()
Array.prototype.forEach()
Array.prototype.every()
Array.prototype.some()
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values