Here you can find the source of intersect
/**/* www .j av a 2 s . co m*/ * Compare this array with another one and return an array with all the items * that are in both arrays. * @jsver 1.8+ * * @param {Array} otherArray The array to compare to * @return {Array} An array with all items in this array and otherArray */ Array.prototype.intersect = function(otherArray) [ i for each( i in this ) if( otherArray.has( i ) ) ];
Array.prototype.intersect = function(a) { return this.filter(function(x) { return a.indexOf(x) >= 0; });
Array.intersect = function(a, b){ return a.uniquelize().each(function(o){return b.contains(o) ? o : null}); };
Array.prototype.intersect = function(ar) { var results = []; for (var i = 0, len = this.length; i < len; i++) { for (var j = 0, len2 = ar.length; j < len2; j++) { if (this[i] === ar[j]) { var found = false; for (var k = 0, len3 = results.length; k < len3; k++) { if (ar[j] === results[k]) { found = true; ...
Array.prototype.intersect = function (arr) { return this.filter(function (el, idx) { return arr.indexOf(el) >= 0; }).unique(); };