JavaScript .values()

Anonymous contributor's avatar
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.

  • 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

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:

95
87
92

Codebyte Example

In this example, .values() returns an iterator of stock quantities, which are printed using a for...of loop:

Code
Output
Loading...

All contributors

Contribute to 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