//计算两个数组的交集
let a = [1, 2, 3, 4, 5, 6, 7, 8];
let b = [2, 4, 5, 6, 1];
let ex = a.filter(n => b.includes(n)); // 相交 b.includes(n) 不相交取反
console.log(ex);
计算两个数组的交集
最新推荐文章于 2023-05-18 10:00:06 发布
//计算两个数组的交集
let a = [1, 2, 3, 4, 5, 6, 7, 8];
let b = [2, 4, 5, 6, 1];
let ex = a.filter(n => b.includes(n)); // 相交 b.includes(n) 不相交取反
console.log(ex);