Categories
JavaScript Answers

How to map over an object and change one properties value using JavaScript?

Spread the love

To map over an object and change one properties value using JavaScript, we use the spread operator.

For instance, we write

const original = { a: 1, b: 2 };
const copy = { ...original, c: 3 };

to spread the properties of the original object into the copy object.

And we add the c property to copy to set ites c property to 3.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.