Nodejs Array Contain containsAll(items)

Here you can find the source of containsAll(items)

Method Source Code

// Return whether all of a list of values exists in an array
Array.prototype.containsAll = function(items)
{
   for(var i = 0; i<items.length; i++) {
      if(this.indexOf(items[i]) == -1)
         return false;
   }/*from  w  w w .  j a  v a 2 s  .  c  o m*/
   return true;
};

Related

  1. contains(what)
    Array.prototype.contains = function (what) {
      var contains = false;
      if (typeof what !== 'function') {
        this.forEach(function (item) {
          if (contains) return;
          contains = (item === what);
        });
        return contains;
      this.forEach(function (item) {
        if (contains) return;
        contains = what(item);
      });
      return contains;
    };
    
  2. contains(x)
    Array.prototype.contains=function(x){
     for(i in this){
       if((x.city==this[i].city || x.firstName==this[i].firstname || x.lastName==this[i].lastname))
         return true;
     return false;
    
  3. contains(x)
    Array.prototype.contains = function (x) {
        return this.indexOf(x) > -1;
    };
    
  4. containsAll(c)
    Array.prototype.containsAll = function(c) {
        for (var i = c.length - 1; i >= 0; i--) {
            if (!this.contains(c[i])) {
                return false;
        return true;
    };
    
  5. containsAll(elements)
    Array.prototype.containsAll = function(elements) {
      for (var i = 0; i < elements.length; i++) {
        if (!this.contains(elements[i])) {
          return false;
      return true;
    };
    
  6. containsAny(c)
    Array.prototype.containsAny = function(c) {
        for (var i = c.length - 1; i >= 0; i--) {
            if (this.contains(c[i])) {
                return true;
        return false;
    };
    
  7. containsAny(items)
    Array.prototype.containsAny = function(items)
      for(var i=0; i<items.length; i++) {
        if(this.indexOf(items[i]) != -1)
          return true;
      return false;
    };
    
  8. containsAnyOf(array)
    Array.prototype.containsAnyOf = function(array) {
      var i = this.length;
      while (i--) {
        for (var x in array) {
          if (this[i] === array[x]) {
            return true;
      return false;
    
  9. containsArray(arr)
    Array.prototype.containsArray = function(arr) {
        for (var i = 0; i < this.length; ++i) {
            if (this[i].length == arr.length) {
                var j;
                for (j = 0; j < arr.length; ++j)
                    if (arr[j] != this[i][j])
                        break;
                if (j == arr.length)
                    return i;
    ...