Last Updated : 23 Jul, 2025
The JavaScript map.values() method is used to return a new Iterator object that contains the value of each element present in Map. The order of the values are in the same order that they were inserted into the map.
Syntax:myMap.values()Parameters:
Example 1:
JavaScript
<script>
let myMap = new Map();
// Adding key value pair with chaining
myMap.set(1, "India");
myMap.set(2, "England");
myMap.set(3, "Canada");
// Creating a Iterator object
const mapIterator = myMap.values();
// Getting values with iterator
console.log(mapIterator.next().value);
console.log(mapIterator.next().value);
console.log(mapIterator.next().value);
</script>
Output :
India
England
Canada
Example 2:
JavaScript
<script>
let myMap = new Map();
// Adding key value pair with chaining
myMap.set(1, "India");
myMap.set(2, "England");
myMap.set(3, "Canada");
myMap.set(4, "Russia");
// Creating a Iterator object
const mapIterator = myMap.values();
// Getting values with iterator
let i = 0;
while (i < myMap.size) {
console.log(mapIterator.next().value);
i++;
}
</script>
Output:
IndiaSupported Browsers:
England
Canada
Russia
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