// 筛选出新数组中和旧数组的重复项,并和旧数组合并 newArr.filter((v) => !oldArr.some(({ ID }) => v.ID == ID)).concat(oldArr)r((v) => !oldArr.some(({ ID }) => v.ID == ID)).concat(oldArr)
测试demo:
let oldArr=[ {ID:1}, {ID:2}, {ID:3}, ] let newArr=[ {ID:2}, {ID:4}, {ID:5}, ] // 筛选出新数组中和旧数组的重复项,并和旧数组合并 newArr.filter((v) => !oldArr.some(({ ID }) => v.ID == ID)).concat(oldArr)