JS找出两个数组中不相同的元素

let arr1 = [0,1,2,3,4,5];
let arr2 = [0,4,6,1,3,9];

const _arr1 =arr1.filter(item1 => !arr2.includes(item1));
const _arr2 =arr2.filter(item2 => !arr1.includes(item2));

const _arr =_arr1.concat(_arr2)
  console.log(_arr1); //[2, 5, 6, 9]
posted @ 2021-06-04 15:09  前端那点事  阅读(4625)  评论(2编辑  收藏  举报