let arr1 = [1,2,7,4,9,5,3,2] let arr2 = [2,3,5,6] //去重利用集合,并返回数组 let uniq = [...new Set(arr1)] console.log(uniq); //求交集 let jiaoji = arr2.filter(item=>uniq.includes(item)) console.log(jiaoji) //求并集 let bingji = new Set([...arr1 , ...arr2]); console.log(bingji) //求差集 let chaji = arr2.filter(item=>!(uniq.includes(item)) ) console.log(chaji)