Map.prototype.entries()
map.entries() Returns:
Iterator · Updated March 13, 2026 · Map and Set map entries iteration
The entries() method returns a new Map Iterator that yields [key, value] pairs in insertion order. Use Map.prototype.entries() when you want both the key and the value while iterating, or when you need to convert a map into an array of tuples.
Syntax
map.entries()
Return Value
Returns an iterator that produces [key, value] arrays for each entry in the map. The iterator object has a next() method that returns {done: false, value: [key, value]} until all entries are exhausted, then returns {done: true}.
Examples
Basic iteration
const scores = new Map([
[alice, 12],
[bob, 9]
]);
for (const [name, score] of scores.entries()) {
console.log(`${name}: ${score}`);
}
// alice: 12
// bob: 9
Convert a map to an array
const settings = new Map([
[theme, dark],
[language, en]
]);
console.log([...settings.entries()]);
// [[theme, dark], [language, en]]
Manual iteration with next()
const ids = new Map([
[first, 101],
[second, 102]
]);
const iterator = ids.entries();
console.log(iterator.next().value);
// [first, 101]
console.log(iterator.next().value);
// [second, 102]
Using with Array methods
const products = new Map([
[apple, 1.50],
[banana, 0.75]
]);
const expensive = [...products.entries()]
.filter(([name, price]) => price > 1.00);
console.log(expensive);
// [[apple, 1.50]]
See Also
- Map.prototype.keys() — iterate over keys only
- Map.prototype.values() — iterate over values only
- Set.prototype.entries() — the Set variant of entries()
- Array.prototype.entries() — the Array variant of entries()