JavaScript .values()
Anonymous contributor
Published Oct 14, 2025
Contribute to Docs
The .values() method of a Map object returns a new Map iterator object that contains the values for each element, in insertion order.
This method does not modify the original Map and can be used to iterate through the stored values, excluding the keys.
Syntax
map.values()
Parameters:
This method doesn’t take any parameters.
Return value:
Returns a new iterator object that contains the values from the Map, in the order they were inserted.
Example
In this example, the .values() method retrieves all values stored in a Map object:
const studentScores = new Map([['Alice', 95],['Bob', 87],['Charlie', 92],]);const valuesIterator = studentScores.values();for (const score of valuesIterator) {console.log(score);}
The output of this code is:
958792
Codebyte Example
In this example, .values() returns an iterator of stock quantities, which are printed using a for...of loop:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn JavaScript on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
- Beginner Friendly.15 hours