UNPKG

simple-utils-js

Version:

前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown

15 lines (12 loc) 376 B
/** * @description: 创建唯一值的数组,这个数组包含所有给定数组都包含的元素 * @param {*} arr The array * @return {*} array */ const intersection = (a, b) => { const s = new Set(b); return a.filter(x => s.has(x)); }; // ES6 includes // const intersection = (arr, values) => arr.filter(v => values.includes(v)); module.exports = intersection