Is there a native method in JavaScript for mapping over objects, similar to Array.prototype.map? For example, given an object like this:
myObject = { ‘a’: 1, ‘b’: 2, ‘c’: 3 }
I want to use a method like this: newObject = myObject.map(function (value, label) { return value * value; });
// newObject should be { ‘a’: 1, ‘b’: 4, ‘c’: 9 }
Does JavaScript have a map function for objects? I’m specifically looking for a solution that works in Node.js, so cross-browser compatibility is not a concern.