JavaScript Map values() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Map

Definition

map.values() returns an iterator that gives you every value stored in the Map, one by one, in the order the keys were added. It does not give the keys. The iterator is not an array: wrap it in Array.from() or spread it with [...map.values()] when you need an array. Keys can be any value (SameValueZero).

Remember
map.values()  → iterator of values (not keys)

for (const v of map.values())  → loop
Array.from(map.values())       → array
[...map.values()]              → array

order = insertion order
iterator can be used only once

Syntax

Call it on a Map. It takes no arguments and is usually used with for...of or Array.from().

JavaScript
map.values()
CallWhat it does
map.values()An iterator of the values of the Map.
Array.from(map.values())Turn the values into an array.
[...map.values()]Spread the values into an array.

Built into JavaScript since ES2015. To get keys instead, see keys(). To get both, see entries().

Library declarations
JavaScript
map.values()   // returns a Map Iterator of values

// no parameters
// order: insertion order

Parameters

ParameterDescription
(none)This method takes no parameters. Call it as map.values().

Return Value

Return ValueDescription
Map IteratorAn iterator of the stored values, in insertion order. Use it once; call values() again for a second loop.

JavaScript Examples

Example 1 — Loop Over the Values

Print every value with for...of, in the order the keys were added.

JavaScript
const ages = new Map();
ages.set("Ann", 31);
ages.set("Bob", 27);
ages.set("Carl", 40);

for (const age of ages.values()) {
  console.log(age);
}
Try It Yourself

How It Works

  1. Ask for the values. ages.values() returns an iterator. for...of reads each value in turn.
  2. Insertion order. The ages come out in the order the keys were added: Ann, then Bob, then Carl.
  3. Keys are not included. Only 31, 27, and 40 print. The names stay out of this loop.

Example 2 — Turn Values into an Array

Use Array.from() and the spread operator to get a plain array of values.

JavaScript
const scores = new Map();
scores.set("Ann", 10);
scores.set("Bob", 20);

const from = Array.from(scores.values());
const spread = [...scores.values()];

console.log(JSON.stringify(from));    // [10,20]
console.log(JSON.stringify(spread));  // [10,20]
console.log(from === spread);         // false
Try It Yourself

How It Works

  1. Array.from builds a new array. Array.from(scores.values()) walks the iterator and collects every value.
  2. Spread does the same job. [...scores.values()] also builds an array with the same numbers.
  3. Two separate arrays. The contents match, but from === spread is false because each call creates a new array.

Example 3 — An Iterator Can Be Used Only Once

Store the iterator in a variable. The second loop finds nothing left.

JavaScript
const tags = new Map();
tags.set(1, "a");
tags.set(2, "b");

const it = tags.values();

const first = [];
for (const v of it) {
  first.push(v);
}
console.log(first.join(","));   // a,b

const second = [];
for (const v of it) {
  second.push(v);
}
console.log(second.length);     // 0
console.log([...tags.values()].join(","));  // a,b
Try It Yourself

How It Works

  1. The first loop empties the iterator. Both values are collected into first, so the iterator is finished.
  2. A finished iterator stays empty. The second loop over the same it finds nothing, so length is 0.
  3. Call values() again for a fresh pass. tags.values() creates a new iterator, so the third line still prints a,b.

Browser & Runtime Support

Map.prototype.values() is part of ES2015 (ES6), together with keys(), entries(), and forEach().

✓ Baseline · ES2015

Map.prototype.values()

Works in every modern browser, plus Node.js, Deno, and Bun.

98% Modern browser support
Google Chrome 36+ · Desktop & Mobile
Full support
Mozilla Firefox 6+ · Desktop & Mobile
Full support
Apple Safari 8+ · macOS & iOS
Full support
Microsoft Edge 12+
Full support
Node.js 0.12+ · every current release
Supported
Deno All releases
Supported
Internet Explorer IE 11 · no constructor argument
Basic
Map.prototype.values() Excellent

Bottom line: Safe to use in any modern browser and runtime. values() has been part of Map since ES2015.

Frequently Asked Questions

It returns an iterator of every value in the Map, in insertion order. It does not return an array unless you wrap it with Array.from() or spread.
No. Only the stored values. Use keys() for keys, or entries() for [key, value] pairs.
A plain for...of over a Map walks entries (pairs). values() walks only the values.
No. Once it is finished it stays finished. Call map.values() again when you need a second loop.
No. It only reads. The Map stays the same.

Next: entries()

Need keys or pairs instead? Open keys() or entries() next.

entries() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful