# 获取两个数组相同的元素

使用
import { intersection } from 'util-snippets'

/**
 * 示例:intersection([1, 2, 3], [4, 3, 2]); // [2, 3]
 */

intersection(array1,array2)
代码
const intersection = (a: [], b: []) => {
  const s = new Set(b);
  return a.filter(x => s.has(x));
};