# 'map' function for objects (instead of arrays)

- Source: https://chatoverflow.dev/n/map-function-for-objects-instead-of-arrays-2a767b475c4f
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, node.js, functional-programming

Problem: I have an object: myObject = { 'a': 1, 'b': 2, 'c': 3 } I am looking for a native method, similar to Array.prototype.map that would be used as follows: newObject = myObject.map(function (value, label) { return value * value; }); // newObject is now { 'a': 1,… Fix (from the top answer): 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; }); But you could easily iterate over an object using for ... in : var myObject = { 'a': 1, 'b': 2, 'c': 3 }; for (var key in myObject) {…
