Map.keys() returns a MapIterator object which can be converted to Array using Array.from:

let keys = Array.from( myMap.keys() );
// ["a", "b"]

EDIT: you can also convert iterable object to array using spread syntax

let keys =[ ...myMap.keys() ];
// ["a", "b"]
Answer from pawel on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map › keys
Map.prototype.keys() - JavaScript - MDN Web Docs - Mozilla
js · const myMap = new Map(); myMap.set("0", "foo"); myMap.set(1, "bar"); myMap.set({}, "baz"); const mapIter = myMap.keys(); console.log(mapIter.next().value); // "0" console.log(mapIter.next().value); // 1 console.log(mapIter.next().value); // {} Map.prototype.entries() Map.prototype.values() Was this page helpful to you?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map
Map - JavaScript - MDN Web Docs - Mozilla
February 16, 2026 - The Map object holds key-value pairs and remembers the original insertion order of the keys. Any value (both objects and primitive values) may be used as either a key or a value.
🌐
W3Schools
w3schools.com › jsref › jsref_map_keys.asp
JavaScript Map keys() Method
JS Arrays · Array[ ] Array( ) at() concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() flat() flatMap() forEach() from() includes() indexOf() isArray() join() keys() lastIndexOf() length map() of() pop() prototype push() reduce() reduceRight() rest (...) reverse() shift() slice() some() sort() splice() spread (...) toReversed() toSorted() toSpliced() toString() unshift() values() valueOf() with() JS Boolean ·
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-map-keys-method
JavaScript Map keys() Method - GeeksforGeeks
July 15, 2025 - JS Tutorial · Web Tutorial · ... : 15 Jul, 2025 · The Map.keys() method is used to extract the keys from a given map object and return the iterator object of keys....
🌐
Codecademy
codecademy.com › docs › javascript › map › .keys()
JavaScript | Map | .keys() | Codecademy
October 28, 2025 - The .keys() method returns a new map iterator object containing the keys of each element in the map, respecting the insertion order.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map › get
Map.prototype.get() - JavaScript - MDN Web Docs - Mozilla
The get() method of Map instances returns the value corresponding to the key in this Map, or undefined if there is none. Object values are returned as the same reference that was originally stored, not as a copy, so mutations to the returned object will be reflected anywhere that reference is held, including inside the Map. const map = new Map(); map.set("bar", "foo"); console.log(map.get("bar")); // Expected output: "foo" console.log(map.get("baz")); // Expected output: undefined · js ·
🌐
Esdiscuss
esdiscuss.org › topic › maps-with-object-keys
Maps with object keys
I'm trying to work with ES6 Map objects and I ran into an interesting problem. I want to index/group based on several key values. Let's say my original data is something like: ```js [{x:3,y:5,z:3},{x:3,y:4,z:4},{x:3,y:4,z:7},{x:3,y:1,z:1},{x:3,y:5,z:4}] ``` I want to group it based on the x and y property values, so I want the result to look something like: ```js {x:3,y:5} ==> {x:3,y:5,z:3},{x:3,y:5,z:4} {x:3,y:4} ==> {x:3,y:4,z:4},{x:3,y:4,z:7} {x:3,y:1} ==> {x:3,y:1,z:1} ``` However, as the docs and draft say maps detect existence ( `Map.prototype.has ( key )`) for object the same way `===` works for objects (specified in `SameValueZero(x, y)`).
Find elsewhere
🌐
Justin Fagnani
justinfagnani.com › 2024 › 11 › 09 › composite-map-keys-in-javascript-with-bitsets
Composite Map Keys in JavaScript with Bitsets
November 9, 2024 - Nested Maps work by doing successive lookups with your keys, like map.get(o1)?.get(o2). The problem is that you need a lot of Map instances. You're building a tree of maps, so there can be reuse due to branching, but at the limit, for a set of key size of K objects and N keys you need up to N * (K - 1) Maps.
Top answer
1 of 6
39

This is not a Map object. It's just a regular object. So, use Object.entries and then use map on the key value pair:

const map = {"a": 1, "b": 2, "c": 3};
const mapped = Object.entries(map).map(([k,v]) => `${k}_${v}`);
console.log(mapped);

Object.entries returns:

[["a",1],["b",2],["c",3]]

Then loop through each of those inner arrays and create the string using template literals


If you have a Map object, use Array.from(map) to get the entries of the map and use the second parameter of Array.from to go over each entry and create the desired string

Array.from(map, ([k,v]) => `${k}_${v}`)
2 of 6
16

It's not a map, it's an object. (You might consider using a Map, though.)

To get its properties as key/value pairs, you can use Object.entries, which you can then apply map to:

map = Object.entries(map).map(([key, value]) => key + "_" + value);

Object.entries is relatively new, but easily polyfilled for older environments.

Live Example:

var map = {"a": 1, "b": 2, "c": 3};
map = Object.entries(map).map(([key, value]) => key + "_" + value);
console.log(map);


Or, using a Map, you can use its built-in entries method, which returns an iterable, passing it into Array.from and using Array.from's mapping callback:

var map = new Map([
  ["a", 1],
  ["b", 2],
  ["c", 3]
]);
map = Array.from(map.entries(), ([key, value]) => key + "_" + value);
console.log(map);

(Or expand the iterable into an array — [...map.entries()] — and use map on it, but the above avoids a temporary throw-away array.)

In both cases, I'm using destructuring in the parameter list of the arrow function, which receives an array in [key, value] format.

🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Map and Set
Map – is a collection of keyed values. ... new Map([iterable]) – creates the map, with optional iterable (e.g.
🌐
W3Schools
w3schools.com › js › js_maps.asp
JavaScript Maps
JS Examples JS HTML DOM JS HTML ... JS Bootcamp JS Certificate JS Reference ... A JavaScript Map is an object that can store collections of key-value pairs, similar to a dictionary in other programming languages....
🌐
Google
developers.google.com › google maps platform › web › maps javascript api › set up the maps javascript api
Set up the Maps JavaScript API | Google for Developers
To create an API key, navigate to the Google Maps Platform Credentials page and select \"Create credentials \\\u003e API key.\" Restricting API keys to specific applications and APIs is strongly recommended for security and to prevent financial ...
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript map keys method
JavaScript - Map.keys() Method
September 1, 2008 - In JavaScript, the Map.keys() method does not accept any parameters and returns a new iterator object that contains the keys for each element present in the Map object, in insertion order.
🌐
Medium
khotsufyan.medium.com › creating-a-unique-key-map-in-javascript-8968d5ada1ae
Creating Maps with unique object keys in JavaScript | by Sufyan Khot | Medium
March 7, 2023 - For example, Java has the well known HashMap, which stores data in buckets, and each bucket is located by the value of its key. Maps in JavaScript are a bit different. Although they were created to make it convenient for us to store objects as keys, there is a problem.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › map
Mastering JS
May 29, 2019 - Here's how you can use date-fns-tz to work with timezones, and alternatives for working with timezones in vanilla JS.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map › has
Map.prototype.has() - JavaScript - MDN Web Docs
Returns true if an entry with the specified key exists in the Map object; otherwise false. js · const myMap = new Map(); myMap.set("bar", "foo"); console.log(myMap.has("bar")); // true console.log(myMap.has("baz")); // false · Map · Map.prototype.delete() Map.prototype.get() Map.prototype.set() ...