Open this example in the interactive library
Source code
const a = [1, 2, 3],
b = new Set([2, 3, 4]);
console.log(a.filter((x) => b.has(x)));
Sample output
[ 2, 3 ]

Find an intersection. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const a = [1, 2, 3],
b = new Set([2, 3, 4]);
console.log(a.filter((x) => b.has(x)));
[ 2, 3 ]