Nodejs Array Intersect intersect(array)

Here you can find the source of intersect(array)

Method Source Code

Array.prototype.intersect = function(array){
  return(this.filter(function(n){ return array.include(n); }));
};

Related

  1. intersect(a, b)
    Array.intersect = function(a, b){
         return a.uniquelize().each(function(o){return b.contains(o) ? o : null});
    };
    
  2. intersect(ar)
    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;
    ...
    
  3. intersect(arr)
    Array.prototype.intersect = function (arr) {
      return this.filter(function (el, idx) {
        return arr.indexOf(el) >= 0;
      }).unique();
    };
    
  4. intersect(arr, comparer)
    Array.prototype.intersect = function (arr, comparer) {
      comparer = comparer || EqualityComparer;
      return this.distinct(comparer).where(function (t) {
        return arr.contains(t, comparer);
      });
    };
    
  5. intersect(array)
    Array.prototype.intersect = function (array) {
        array = Array.isArray(array) ? array : [];
        return this.filter(function (n) {
            return array.indexOf(n) != -1;
        });
    };
    
  6. intersect(array)
    Array.prototype.intersect = function(array) {
      return this.filter((x) => array.indexOf(x) != -1);
    };
    
  7. intersect(array)
    Array.prototype.intersect = function(array){
      if(this.length>array.length) return '';
      var equals = true,
          concat = '';
      for(var i = 0; i < this.length-1; i++){
        if(this[i+1] != array[i]){
          equals = false;
          break;
      if(equals){
        concat = this.reduce((acc,k,i) => acc + (i<this.length?k:''), '');
        concat = array.reduce((acc,k,i) => acc + (i>=this.length-1?k:''), concat);
        return concat;
      return '';
    
  8. intersect(ary)
    Array.prototype.intersect = function (ary) {
        return this.union(ary).filter(x => this.contains(x) && ary.contains(x));
    };
    
  9. intersect(b)
    Array.prototype.intersect = function(b) {
      var array = new Array();
      var ua = this.uniquelize();
      var length = ua.length;
      for (var i = 0; i < length; i++) {
        if (b.inArray(ua[i])) {
          array.push(ua[i]);
      return array;
    };