There is now a Set.prototype.intersection
function. See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection
// Lets say you have 2 arrays
const arr1 = [1,3,5,7,9,1];
const arr2 = [1,4,9,1,9];
//convert them to Sets
const set1 = new Set(arr1);
const set2 = new Set(arr2);
console.log(set2.intersection(set1)); // Set(2) { 1, 9 }