筛选出两个数组不相同的元素

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)

  

上一篇:STM32+USART+蓝牙模块(BT04)


下一篇:线段树脑洞题 P2184 贪婪大陆