So .map itself only offers one value you care about... That said, there are a few ways of tackling this:

// instantiation
const myMap = new Map([
  [ "A", 1 ],
  [ "B", 2 ]
]);

// what's built into Map for you
myMap.forEach( (val, key) => console.log(key, val) ); // "A 1", "B 2"

// what Array can do for you
Array.from( myMap ).map(([key, value]) => ({ key, value })); // [{key:"A", value: 1}, ... ]

// less awesome iteration
let entries = myMap.entries( );
for (let entry of entries) {
  console.log(entry);
}

Note, I'm using a lot of new stuff in that second example... ...Array.from takes any iterable (any time you'd use [].slice.call( ), plus Sets and Maps) and turns it into an array... ...Maps, when coerced into an array, turn into an array of arrays, where el[0] === key && el[1] === value; (basically, in the same format that I prefilled my example Map with, above).

I'm using destructuring of the array in the argument position of the lambda, to assign those array spots to values, before returning an object for each el.

If you're using Babel, in production, you're going to need to use Babel's browser polyfill (which includes "core-js" and Facebook's "regenerator").
I'm quite certain it contains Array.from.

Answer from LetterEh on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map › entries
Map.prototype.entries() - JavaScript | MDN
July 20, 2025 - js · const myMap = new Map(); myMap.set("0", "foo"); myMap.set(1, "bar"); myMap.set({}, "baz"); const mapIter = myMap.entries(); console.log(mapIter.next().value); // ["0", "foo"] console.log(mapIter.next().value); // [1, "bar"] console.log(mapIter.next().value); // [Object, "baz"] Map.prototype.keys() Map.prototype.values() Was this page helpful to you?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › map
Array.prototype.map() - JavaScript | MDN
Sometimes this pattern goes to its extreme and the only useful thing that map() does is causing side effects. js · const products = [ { name: "sports car" }, { name: "laptop" }, { name: "phone" }, ]; products.map((product) => { product.price = 100; }); As mentioned previously, this is an anti-pattern.
🌐
W3Schools
w3schools.com › jsref › jsref_map_entries.asp
W3Schools.com
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-entries-method
JavaScript Map entries() Method - GeeksforGeeks
July 11, 2025 - The Map.entries() method returns the [key, value] pairs of all the elements of a map in the order of their insertion.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map
Map - JavaScript | MDN
February 16, 2026 - js · const myMap = new Map(); myMap.set(0, "zero"); myMap.set(1, "one"); for (const [key, value] of myMap) { console.log(`${key} = ${value}`); } // 0 = zero // 1 = one for (const key of myMap.keys()) { console.log(key); } // 0 // 1 for (const value of myMap.values()) { console.log(value); } // zero // one for (const [key, value] of myMap.entries()) { console.log(`${key} = ${value}`); } // 0 = zero // 1 = one ·
Find elsewhere
🌐
Educative
educative.io › answers › what-is-mapentries-method-in-javascript
What is Map.entries method in JavaScript?
The entries method of the Map object will return an iterator object which contains key-value pair for each element of the map object in the insertion order.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Map › Map
Map() constructor - JavaScript | MDN
Each element must be an object with two properties: 0 and 1, which correspond to the key and value (for example, [[1, "one"],[2, "two"]]). If you don't specify this parameter, or its value is null or undefined, the new Map is empty. js · const myMap = new Map([ [1, "one"], [2, "two"], [3, ...
🌐
Codecademy
codecademy.com › docs › javascript › map › entries()
JavaScript | Map | entries() | Codecademy
October 14, 2025 - The entries() method in JavaScript Maps returns an iterator containing each key–value pair in insertion order.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Map and Set
If we have a plain object, and we’d like to create a Map from it, then we can use built-in method Object.entries(obj) that returns an array of key/value pairs for an object exactly in that format.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript map object
The Essential Guide to JavaScript Map: How To Use Maps Effectively
October 6, 2023 - delete(key) – removes an element specified by the key. It returns if the element is in the map, or false if it does not. entries() – returns a new Iterator object that contains an array of [key, value] for each element in the map object.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-iterate-over-map-elements-in-javascript
How to iterate over Map elements in JavaScript ? - GeeksforGeeks
Array.from(myMap.entries()).forEach(([key, value]) => { console.log(key + " is " + value); }); Example: This example demonstrates the implementation of the above-explained approach. ... function iterateMap() { let myMap = new Map(); myMap.set("Cricket", "sport"); myMap.set("Apple", "fruit"); Array.from(myMap.entries()).forEach(([key, value]) => { console.log(key + " is " + value); }); } iterateMap();
Published   July 23, 2025
Top answer
1 of 16
2603

There is no native map to the Object object, but how about this:

var myObject = { 'a': 1, 'b': 2, 'c': 3 };

Object.keys(myObject).forEach(function(key, index) {
  myObject[key] *= 2;
});

console.log(myObject);
// => { 'a': 2, 'b': 4, 'c': 6 }

But you could easily iterate over an object using for ... in:

var myObject = { 'a': 1, 'b': 2, 'c': 3 };

for (var key in myObject) {
  if (myObject.hasOwnProperty(key)) {
    myObject[key] *= 2;
  }
}

console.log(myObject);
// { 'a': 2, 'b': 4, 'c': 6 }

Update

A lot of people are mentioning that the previous methods do not return a new object, but rather operate on the object itself. For that matter I wanted to add another solution that returns a new object and leaves the original object as it is:

var myObject = { 'a': 1, 'b': 2, 'c': 3 };

// returns a new object with the values at each key mapped using mapFn(value)
function objectMap(object, mapFn) {
  return Object.keys(object).reduce(function(result, key) {
    result[key] = mapFn(object[key])
    return result
  }, {})
}

var newObject = objectMap(myObject, function(value) {
  return value * 2
})

console.log(newObject);
// => { 'a': 2, 'b': 4, 'c': 6 }

console.log(myObject);
// => { 'a': 1, 'b': 2, 'c': 3 }

Array.prototype.reduce reduces an array to a single value by somewhat merging the previous value with the current. The chain is initialized by an empty object {}. On every iteration a new key of myObject is added with twice the key as the value.

Update

With new ES6 features, there is a more elegant way to express objectMap.

const objectMap = (obj, fn) =>
  Object.fromEntries(
    Object.entries(obj).map(
      ([k, v], i) => [k, fn(v, k, i)]
    )
  )
  
const myObject = { a: 1, b: 2, c: 3 }

console.log(objectMap(myObject, v => 2 * v)) 

2 of 16
618

How about a one-liner in JS ES10 / ES2019 ?

Making use of Object.entries() and Object.fromEntries():

let newObj = Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, v * v]));

The same thing written as a function:

function objMap(obj, func) {
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, func(v)]));
}

// To square each value you can call it like this:
let mappedObj = objMap(obj, (x) => x * x);

This function uses recursion to square nested objects as well:

function objMap(obj, func) {
  return Object.fromEntries(
    Object.entries(obj).map(([k, v]) => 
      [k, v === Object(v) ? objMap(v, func) : func(v)]
    )
  );
}

// To square each value you can call it like this:
let mappedObj = objMap(obj, (x) => x * x);

With ES7 / ES2016 you can't use Objects.fromEntries, but you can achieve the same using Object.assign in combination with spread operators and computed key names syntax:

let newObj = Object.assign({}, ...Object.entries(obj).map(([k, v]) => ({[k]: v * v})));

ES6 / ES2015 Doesn't allow Object.entries, but you could use Object.keys instead:

let newObj = Object.assign({}, ...Object.keys(obj).map(k => ({[k]: obj[k] * obj[k]})));

ES6 also introduced for...of loops, which allow a more imperative style:

let newObj = {}

for (let [k, v] of Object.entries(obj)) {
  newObj[k] = v * v;
}


array.reduce()

Instead of Object.fromEntries and Object.assign you can also use reduce for this:

let newObj = Object.entries(obj).reduce((p, [k, v]) => ({ ...p, [k]: v * v }), {});


Inherited properties and the prototype chain:

In some rare situation you may need to map a class-like object which holds properties of an inherited object on its prototype-chain. In such cases Object.keys() and Object.entries() won't work, because these functions do not include the prototype chain.

If you need to map inherited properties, you can use for (key in myObj) {...}.

Here is an example of such situation:

const obj1 = { 'a': 1, 'b': 2, 'c': 3}
const obj2 = Object.create(obj1);  // One of multiple ways to inherit an object in JS.

// Here you see how the properties of obj1 sit on the 'prototype' of obj2
console.log(obj2)  // Prints: obj2.__proto__ = { 'a': 1, 'b': 2, 'c': 3}

console.log(Object.keys(obj2));  // Prints: an empty Array.
console.log(Object.entries(obj2));  // Prints: an empty Array.

for (let key in obj2) {
  console.log(key);              // Prints: 'a', 'b', 'c'
}

However, please do me a favor and avoid inheritance. :-)

🌐
DEV Community
dev.to › mlgvla › javascript-using-the-map-object-322e
JavaScript: Using the Map Object - DEV Community
March 1, 2022 - [Map Entries] { [ 'dog', 'Fido' ], [ 'cat', 'Milo' ], [ 'bird', 'Polly' ], [ 'turtle', 'Yertle' ] } dog,Fido cat,Milo bird,Polly turtle,Yertle
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_map_entries_method.htm
JavaScript - Map.entries() Method
In the following example, we are using the JavaScript Map.entries() method to return the [key, value] pairs of all the elements of the Map object in the order of their insertion.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › fromEntries
Object.fromEntries() - JavaScript | MDN
October 30, 2025 - const entries = new Map([ ["foo", "bar"], ["baz", 42], ]); const obj = Object.fromEntries(entries); console.log(obj); // Expected output: Object { foo: "bar", baz: 42 } js · Object.fromEntries(iterable) iterable · An iterable, such as an Array or Map, containing a list of objects.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-map
Map in JS - GeeksforGeeks
JS Tutorial · Web Tutorial · A to Z Guide · Projects · OOP · DOM · Set · Map · Math · Number · Boolean · Exercise · Last Updated : 23 Sep, 2025 · A JavaScript Map holds key-value pairs and similar to Hash Map or Dictionary in other ...
Published   September 23, 2025
🌐
Medium
medium.com › @sonu9506517825 › map-methods-in-javascript-a048f48a9cce
MAP Methods in JavaScript. it is store key - value pair as… | by Sonu Verma | Medium
December 6, 2022 - MAP Methods in JavaScript it is store key - value pair as insertion order. 1. size : time complexity O(N) | space complexity O(N) calculate the number of element in map return count of element in …
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › entries
Object.entries() - JavaScript | MDN
js · // Strings have indices as enumerable own properties console.log(Object.entries("foo")); // [ ['0', 'f'], ['1', 'o'], ['2', 'o'] ] // Other primitives except undefined and null have no own properties console.log(Object.entries(100)); // [] The Map() constructor accepts an iterable of entries.
🌐
Reddit
reddit.com › r/javascript › why you should prefer map over object in javascript
r/javascript on Reddit: Why You Should Prefer Map Over Object In JavaScript
June 20, 2022 - Having said that, I will make a shout-out to Array.from() for its optional second argument which is a callback which will map over the iterator at the time it is being converted to an array – not after (saving a loop). ... Array.from() is definitely more handy than new Array! ... I totally agree. It seems natural ro iterate over an iterable object. And yeah it's really time for js to implement some more things that are absolutely standard in other languages.