map function for objects instead of arrays

0 votes

I have an object:

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

I'm seeking for a native method that works like Array.prototype. This is a map that might be utilised as follows:

newObject = myObject.map(function (value, label) {
    return value * value;
});

// newObject is now { 'a': 1, 'b': 4, 'c': 9 }

Is there a map method for objects in JavaScript? (I want this for Node.JS, so I'm not concerned about cross-browser compatibility.)

Nov 16, 2022 in Java by Nicholas
• 7,760 points

edited 5 days ago 8 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP