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:
- This method does not accept any parameters.
Example 1:
<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:
<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:
India
England
Canada
Russia
Supported Browsers:
- Chrome 38
- Edge 12
- Firefox 19
- Opera 25
- Safari 8

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
