题目描述var arr = [1,2];var allArr = [{id:1,name:"s"},{id:2,name:"ds"},{id:3,name:"gg"}]var finalArr = [];// 最终结果finalArr = [{id:3,name:"gg"}];
2 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
这个是不是你要的
var arr = [1,2]; var allArr = [{id:1,name:"s"},{id:2,name:"ds"},{id:3,name:"gg"}] var finalArr = []; for(var i = 0, max = allArr .length; i < max; i++ ){ var newArrid = newArr[i].id; if(newArrid != arr[i]){ finalArr.push(newArr[i]); } } console.log(finalArr);
添加回答
举报
0/150
提交
取消