How can I find and update values in an array of objects?

I have an array of objects. I want to find by some field, and then to change it:

var item = {...}
var items = [{id:2}, {id:2}, {id:2}];

var foundItem = items.find(x => x.id == item.id);
foundItem = item;

I want it to change the original object. How? (I don’t care if it will be in Lodash too.)

9 Answers
9

Leave a Comment