let arr1=[1,2,3]
let arr2=[1,2,3,4,5,6]
我想比较2个数组并获取不在arr1
即输出为arr3=[4,5,6]
使用lodash / Javascript的方法
答案 0 :(得分:1)
const arr1=[1,2,3];
const arr2=[1,2,3,4,5,6]
const intersection = arr2.filter(elm => !arr1.includes(elm));
console.log(intersection);
答案 1 :(得分:0)
使用lodash中的diffrence方法
_.difference([1,2,3,4,5,6], [1,2,3]);