# 获取两个数组相同的元素
使用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));
};
← 获取数组中最小的N个值 其它类型转数组 →