let array1=[2,5,6,8,9,0,11];
let array2=[2,4,6,7,8,10,"11","a"];
1、编写函数intersection(arr1,arr2)返回两个数组的交集数组
//交集
intersection(array1,array2)
function intersection(arr1,arr2){
// 在A在B
let newArray=array1.filter((item)=>{
return array2.includes(item);
})
console.log(newArray);
}
2、编写函数difference(arr1,arr2)返回两个数组的差集数组
difference(array1,array2)
function difference(arr1,arr2){
let newArray=array1.filter((item)=>{
return !array2.includes(item);
})
console.log(newArray);
}