Array.prototype.entries
Returns a new array iterator object that contains the key/value pairs for each index in the array
Syntax
array.entries()Return Value
A new iterable iterator object
Examples
const arr = ['a', 'b', 'c'];
const iterator = arr.entries();
console.log(iterator.next().value); // [0, 'a']
console.log(iterator.next().value); // [1, 'b']const arr = ['x', 'y', 'z'];
for (const [index, element] of arr.entries()) {
console.log(index, element);
}
// 0 'x', 1 'y', 2 'z'const arr = [10, 20, 30];
const entries = [...arr.entries()];
console.log(entries); // [[0, 10], [1, 20], [2, 30]]Understanding Array.prototype.entries
The Array.prototype.entries method in JavaScript returns a new array iterator object that contains the key/value pairs 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.entries(). When called, it returns a new iterable iterator object. Understanding when and how to use entries() helps you write more expressive, readable code.
Common use cases for Array.prototype.entries include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like array-keys, array-values, object-entries, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Array.prototype.entries 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
Array.prototype.keysReturns a new array iterator object that contains the keys for each index in the array
Array.prototype.valuesReturns a new array iterator object that contains the values for each index in the array
Object.entriesReturns an array of a given object's own enumerable string-keyed property key-value pairs
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.