# 获取两个数组中不同的值
使用import { difference } from 'util-snippets'
/**
* 示例:difference([1, 2, 3], [1, 2, 4]); // [3]
*/
difference(array1,array2);
const difference = (a: [], b: []) => {
const s = new Set(b);
return a.filter(x => !s.has(x));
};
import { difference } from 'util-snippets'
/**
* 示例:difference([1, 2, 3], [1, 2, 4]); // [3]
*/
difference(array1,array2);
const difference = (a: [], b: []) => {
const s = new Set(b);
return a.filter(x => !s.has(x));
};