A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-map-entries-method/ below:

JavaScript Map entries() Method - GeeksforGeeks

JavaScript Map entries() Method

Last Updated : 11 Jul, 2025

JavaScript Map.entries() method is used for returning an iterator object which contains all the [key, value] pairs of each element of the map. It returns the [key, value] pairs of all the elements of a map in the order of their insertion.

The Map.entries() method does not require any argument to be passed and returns an iterator object of the map. 

Syntax:
mapObj.entries();
Parameters: Return value:

Example 1: In this example, a map object "myMap" has been created with three [key, value] pairs, and an iterator object "iterator_obj" method is created which uses Map. entries() method to return the [key, value] pairs of all the elements of a map in the order of their insertion. 

javascript
// creating a map object
let myMap = new Map();

// Adding [key, value] pair to the map
myMap.set(0, 'geeksforgeeks');
myMap.set(1, 'is an online portal');
myMap.set(2, 'for geeks');

// creating an iterator object using Map.entries() method
let iterator_obj = myMap.entries();

// displaying the [key, value] pairs of all the elements of the map
console.log(iterator_obj.next().value);
console.log(iterator_obj.next().value);
console.log(iterator_obj.next().value);

Output
[ 0, 'geeksforgeeks' ]
[ 1, 'is an online portal' ]
[ 2, 'for geeks' ]

Example 2: In this example, a map object "myMap" has been created with three [key, value] pairs, and an iterator object "iterator_obj" method is created which uses Map. entries() method to return the [key, value] pairs of all the elements of a map in the order of their insertion. 

javascript
// creating a map object
let myMap = new Map();

// Adding [key, value] pair to the map
myMap.set(0, 'Maps');
myMap.set(1, 'in JavaScript');

// creating an iterator object using Map.entries() method
let iterator_obj = myMap.entries();

// displaying the [key, value] pairs of all the elements of the map
console.log(iterator_obj.next().value);
console.log(iterator_obj.next().value);

Output
[ 0, 'Maps' ]
[ 1, 'in JavaScript' ]
Applications:

Whenever we want to get all the [key, value] pairs of each element of a map using an iterator object, we use the Map.entries() method. 

Exceptions: Supported Browsers:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4