JavaScript Map entries() Method Last Updated : 12 Jul, 2024 Comments Improve Suggest changes Like Article Like Report 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:It does not require any parameters to be passed.Return value:The Map.entries() method returns the [key, value] pairs of all the elements of a map in the order of their insertion.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:If the variable is not of the Map type then the Map.entries() operation throws a TypeError.If the "iterator_obj.next().value" is used more times as compared to [key, value] pairs of a map, the Map.entries() method returns undefined for all those cases.Supported Browsers:Google Chrome 38 Edge 12 Firefox 20 Opera 25 Safari 8 Comment More infoAdvertise with us Next Article JavaScript Map forEach() Method S Shubrodeep Banerjee Follow Improve Article Tags : Misc JavaScript Web Technologies javascript-map JavaScript-Methods +1 More Practice Tags : Misc Similar Reads JavaScript Map() Constructor The Map() constructor is used to create Map objects in JavaScript. The map is a data structure that stores elements as a key, value pair.Syntax:new Map()new Map(iterable)Parameters:iterable: An iterable object used for iterating through elements, stored as a key, value pair.Return value:A new Map ob 3 min read JavaScript Map constructor Property The map constructor property in JavaScript is used to return the map constructor function for the object. The function which is returned by this property is just the reference to this function, not a map containing the function's name. The JavaScript map constructor, string constructor, and boolean 1 min read JavaScript Map size Property Map is a collection of elements where each element is stored as a Key, value pair. The Map.size property returns the number of key, and value pairs stored in a map.SyntaxmapName.sizeReturn ValueAn integer representing the number of key, value pairs stored in a map.The below examples illustrate the M 1 min read JavaScript Map clear() Method JavaScript Map.clear() method is used for the removal of all the elements from a map and making it empty. It removes all the [key, value] from the map. No arguments are required to be sent as parameters to the Map.clear() method and it returns an undefined return value.Syntax:mapObj.clear()Parameter 3 min read JavaScript Map delete() Method JavaScript Map.delete() method is used to delete the specified element among all the elements that are present in the map. The Map.delete() method takes the key that needs to be removed from the map, thus removing the element associated with that key and returning true. If the key is not present the 3 min read JavaScript Map entries() Method 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 4 min read JavaScript Map forEach() Method JavaScript Map.forEach method is used to loop over the map with the given function and executes the given function over each key-value pair.Syntax:myMap.forEach(callback, value, key, thisArg)Parameters:This method accepts four parameters as mentioned above and described below:callback: This is the f 3 min read JavaScript Map get() Method The Map.get() method in JavaScript is a convenient way to retrieve the value associated with a specific key in a Map object. A Map in JavaScript allows you to store key-value pairs where keys can be of any data type, making it more useful compared to objects, which only allow strings and symbols as 3 min read JavaScript Map has() Method The has() method in JavaScript Map returns a boolean indicating whether a specified element is present in the Map object or not. It returns true if the element is found, otherwise false.Syntax:mapObj.has(key)Parameters:key: It is the key of the element of the map which has to be searched.Return Valu 3 min read JavaScript Map keys() Method The Map.keys() method is used to extract the keys from a given map object and return the iterator object of keys. The keys are returned in the order they were inserted.Syntax:Map.keys()Parameters:This method does not accept any parameters.Return Value:This returns the iterator object that contains k 3 min read Like