直接上代码!
//定义三个数组
let a = [1,3,5,7,9];
let b = [1,2,4,5,7];
let c = [1,3,5,8,7];
const getIntersection = (a,...array)=>{ //...array 表示可以传入多个数组
return a.filter(item=>array.every(elem=>elem.includes(item)))
}
let newArray = getIntersection(a,b,c)
console.log(newArray)
}
代码就不多解释,稍微改一改还能找出多个数组元素值均为对象的的交值
标签:最简,多个,交集,代码,js,let,数组,array From: https://www.cnblogs.com/Dreams-log/p/17560888.html