📜  在数组中查找并更改 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:47.296000             🧑  作者: Mango

代码示例1
var item = {...}
var items = [{id:2}, {id:2}, {id:2}];

var foundIndex = items.findIndex(x => x.id == item.id);
items[foundIndex] = item;