simple-utils-js
Version:
前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown
15 lines (12 loc) • 354 B
JavaScript
/**
* @description: 创建一个具有唯一array值的数组,每个值不包含在其他给定的数组中。
* @param {*} arr The array
* @return {*} array
*/
const difference = (a, b) => {
const s = new Set(b);
let arr = a.filter(x => !s.has(x));
return arr
};
module.exports = difference
// console.log(difference([3, 2, 1], [4, 2]));