let arrA = [{id:1,age:21,res:0},{id:2,age:22,res:0},{id:3,age:23,res:0},{id:4,age:24,res:0}]。
let arrB = [{id:1,age:21,res:0},{id:2,age:22,res:0}]。
然后把arrA变成let arrA = [{id:1,age:21,res:1},{id:2,age:22,res:1},{id:3,age:23,res:0},{id:4,age:24,res:0}]。
https://www.jb51.cc/js/58083.html
arrA.forEach((item) => {
const str = JSON.stringify(item);
arrB.forEach((obj) => {
if (str === JSON.stringify(obj)) item.res = 1;
});
});
console.log('arrA', arrA);