Nodejs Array Different diff

Here you can find the source of diff

Method Source Code

/**/*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 ) ) ];

Related

  1. diff( a )
    Array.prototype.diff = function( a ) {
        return this.filter( function( i ) { return !( a.indexOf( i ) > -1 ); } );
    };
    
  2. diff(B)
    Array.prototype.diff = function (B) {
        return this.filter(function (a) { return B.indexOf(a) < 0; });
    };
    
  3. diff(a)
    Array.prototype.diff = function(a) {
        return this.filter(function(i) {return a.indexOf(i) < 0;});
    };
    
  4. diff(a)
    Array.prototype.diff = function (a) {
        return this.filter(function (e) { return a.indexOf(e) === -1 });
    };