JavaScript (ES2026) reference · Array Methods
JavaScript Array values() Method
Return an iterator of the array's values, the same thing a for…of loop uses.
JavaScript (ES2026) Since ES2015
Syntax
array.values()
Return value
An array iterator.
Examples
const it = ["a", "b"].values();
console.log(it.next(), it.next(), it.next());
Output
{ value: 'a', done: false } { value: 'b', done: false } { value: undefined, done: true }for (const v of [10, 20].values()) console.log(v);
Output
10 20
Version history
| Version | Change |
|---|---|
| JavaScript ES2015 | Added |
Related
array.keys()· Return an iterator of the array's indexes, including indexes of empty slots.array.entries()· Return an iterator of [index, element] pairs, handy for looping with both the index and the value.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial