篩選出兩個數組不相同的元素
let a = [{ name: 'javascript', id: 0 }, { name: 'css', id: 1 }, { name: 'html', id: 2 }]
let b = [{ name: 'css', id: 1 }, { name: 'html', id: 2 }]
let n = [];
for (let i = 0; i < a.length; i++) {
let staA = a[i].id;
let sta = 0;
for(let j = 0; j < b.length; j++){
let staB = b[j].id;
if (staA == staB){
sta++
}
}
if (sta == 0){
n.push(a[i])
}
}
console.log(n)

浙公網安備 33010602011771號