EN
JavaScript - find intersection of two arrays
0
points
In this article, we would like to show you how to find the intersection of two arrays in JavaScript.
Quick solution:
// ONLINE-RUNNER:browser;
const array1 = ['a', 'b'];
const array2 = ['a', 'b', 'c', 'd'];
const result = array1.filter((x) => array2.includes(x));
console.log(result); // [ 'a', 'b' ]
result: