Array.prototype.values()

Returns a new array iterator that yields the value of each element.

Since ES2015 Spec ↗

Syntax

arr.values()

Returns

Array Iterator — An iterator yielding the values of the array.

Examples

console.log([...['a', 'b'].values()]);
Output
[ 'a', 'b' ]
const it = [10, 20].values();
console.log(it.next().value);
Output
10

Notes

This is the same iterator used by `for...of` and the spread operator on arrays. Includes undefined for empty slots in sparse arrays.

Browser & runtime support

EnvironmentSince version
chrome 66
firefox 60
safari 9
edge 12
node 10

See also