Array

Array.prototype.values

Returns a new array iterator object that contains the values for each index in the array

Syntax

JavaScript
array.values()

Return Value

A new iterable iterator object

Examples

Basic Usage
const arr = ['a', 'b', 'c'];
for (const value of arr.values()) {
  console.log(value);
}
// 'a', 'b', 'c'
Practical Example
const numbers = [10, 20, 30];
const vals = [...numbers.values()];
console.log(vals); // [10, 20, 30]
Advanced Usage
const arr = [1, 2, 3];
const iter = arr.values();
console.log(iter.next()); // { value: 1, done: false }

Understanding Array.prototype.values

The Array.prototype.values method in JavaScript returns a new array iterator object that contains the values for each index in the array. It belongs to the Array object and is one of the most widely used methods for working with array values in modern JavaScript and TypeScript applications.

The method signature is array.values(). When called, it returns a new iterable iterator object. Understanding when and how to use values() helps you write more expressive, readable code.

Common use cases for Array.prototype.values include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like array-keys, array-entries, object-values, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Array.prototype.values is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Array Methods

Other methods in the Array object

Related Tools

More Array Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.