📜  数组交集 javascript es6 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:14.513000             🧑  作者: Mango

代码示例2
const intersection = (a, b) => {
  b = new Set(b); // recycling variable
  return [...new Set(a)].filter(e => b.has(e));
};

console.log(intersection([1, 2, 3, 1, 1], [1, 2, 4])); // Array [ 1, 2 ]