var item = {...} var items = [{id:2}, {id:2}, {id:2}]; var foundIndex = items.findIndex(x => x.id == item.id); items[foundIndex] = item;
const updatedData = originalData.map(x => (x.id === id ? { ...x, updatedField: 1 } : x));