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 = item
Given a changed object and an array:
const item = {...} let items = [{id:2}, {id:3}, {id:4}];
Update the array with the new object by iterating over the array:
items = items.map(x => (x.id === item.id) ? item : x)