Javascript Array intersect(otherArray)
/**// w w w .j a va 2s .c o m * Compare this array with another one and return an array with all the items * that are in both arrays. * * @param {Array} otherArray The array to compare to * @return {Array} An array with all items in this array and otherArray */ Array.prototype.intersect = function intersect(otherArray) { return this.filter(function(item) { return otherArray.has(item); }); };