JavaScript Array.prototype.values() Method
The values() method returns an iterator over the elements of an array.
Description
The values() method returns an iterator of the array's elements. It's what for...of uses behind the scenes for arrays. It's useful when an API expects an iterator, or with iterator helpers such as take() and drop(), which process values lazily.
Calling values() is equivalent to arr[Symbol.iterator](), the same iterator for...of and spread syntax use. Like all iterators, the result can only be consumed once: after looping through it, it's exhausted, and you need to call values() again for a fresh one.
The iterator is live: if elements are added to or changed in the array before the iterator reaches them, it sees the new values. Empty slots in sparse arrays produce undefined. Maps and sets have their own values() methods, and Object.values() does the same job for objects.
Syntax
array.values()Return Value
A new array iterator that yields each element.
Example
Browser Support
The following information will show you the current browser support for the Array.prototype.values() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





