Answers for "intersection in javascript arrays"

10

javascript do arrays intersect

let intersection = arrA.filter(x => arrB.includes(x));
Posted by: Guest on March-31-2020
0

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 ]
Posted by: Guest on September-06-2020

Code answers related to "intersection in javascript arrays"

Code answers related to "Javascript"

Browse Popular Code Answers by Language