JS: Array.prototype.values

By Xah Lee. Date: . Last updated: .

New in JS2015.

Return a Iterator (also is a Iterable Object), each entry is the element's value of the array.

Note: this method is not useful, because array itself is a iterable already.

as of 2018-01-01 Array.prototype.values is not supported by Google Chrome, Firefox. It's supported in both as of 2019-10-31.

for (const e of ["a", "b", "c"].values()) { console.log( e ); }

// prints
// a
// b
// c


Array.prototype.values is identical to Array.prototype[Symbol.iterator]

Array.prototype [ Symbol.iterator ]
); // true
BUY ΣJS JavaScript in Depth