Is there a native method in JavaScript for mapping over objects, similar to Array.prototype.map

Is there a native method in JavaScript for mapping over objects, similar to Array.prototype.map? I have an object like this:

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

I want to create a new object using a function that processes each key-value pair, like so:

newObject = myObject.map(function (value, label) {
return value * value;
});
// newObject should be { 'a': 1, 'b': 4, 'c': 9 };

Does JavaScript provide a map function for objects? (I’m using Node.js, so cross-browser compatibility isn’t a concern.)

I’m looking for guidance on using javascript map object techniques to achieve this.

You can use Object.keys() to iterate through the object and reduce() to create a new object.

const myObject = { 'a': 1, 'b': 2, 'c': 3 };
const newObject = Object.keys(myObject).reduce((acc, key) => {
acc[key] = myObject[key] * myObject[key]; // Processing each value
return acc;
}, {});
console.log(newObject); // { 'a': 1, 'b': 4, 'c': 9 }