map function for objects (instead of arrays) map function for objects (instead of arrays) javascript javascript

map function for objects (instead of arrays)


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

var myObject = { 'a': 1, 'b': 2, 'c': 3 };Object.keys(myObject).map(function(key, index) {  myObject[key] *= 2;});console.log(myObject);// => { 'a': 2, 'b': 4, 'c': 6 }