Regarding the question title, I have implemented the following:
Array.prototype.containsAny = function (otherArray) {
for (let i = 0; i < otherArray.length; i++)
if (this.includes(otherArray[i]))
return true;
return false;
};
let set1 = [3, 5, 9];
let set2 = [4, 5];
set1.containsAny(set2);
Is there an alternative approach that may be more efficient?