Here you can find the source of diff
/**/*from w ww . java 2 s .c o m*/ * @fileOverview This file contains array diff and intersect methods for JS 1.8 */ /** * Compare this array with another one and return an array with all the items * in this one that are not in the other. * @jsver 1.8+ * * @param {Array} otherArray The array to compare to * @return {Array} An array with all items in this array not in otherArray */ Array.prototype.diff = function(otherArray) [ i for each( i in this ) if( !otherArray.has( i ) ) ];
Array.prototype.diff = function( a ) { return this.filter( function( i ) { return !( a.indexOf( i ) > -1 ); } ); };
Array.prototype.diff = function (B) { return this.filter(function (a) { return B.indexOf(a) < 0; }); };
Array.prototype.diff = function(a) { return this.filter(function(i) {return a.indexOf(i) < 0;}); };
Array.prototype.diff = function (a) { return this.filter(function (e) { return a.indexOf(e) === -1 }); };