Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array intersection javascript es6

const intersection = (a, b) => {
  b = new Set(b); // recycling variable
  return [...new Set(a)].filter(e => b.has(e));
};

console.log(intersection([1, 2, 3, 1, 1], [1, 2, 4])); // Array [ 1, 2 ]
Source by www.thetopsites.net #
 
PREVIOUS NEXT
Tagged: #array #intersection #javascript
ADD COMMENT
Topic
Name
9+8 =