Nodejs Array Contain containsAny(items)

Here you can find the source of containsAny(items)

Method Source Code

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

Related

  1. contains(x)
    Array.prototype.contains = function (x) {
        return this.indexOf(x) > -1;
    };
    
  2. 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;
    };
    
  3. containsAll(elements)
    Array.prototype.containsAll = function(elements) {
      for (var i = 0; i < elements.length; i++) {
        if (!this.contains(elements[i])) {
          return false;
      return true;
    };
    
  4. containsAll(items)
    Array.prototype.containsAll = function(items)
      for(var i = 0; i<items.length; i++) {
        if(this.indexOf(items[i]) == -1)
          return false;
      return true;
    };
    
  5. 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;
    };
    
  6. 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;
    
  7. 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;
    ...
    
  8. containsArray(array)
    Array.prototype.containsArray = function(array){
        if(!this[0] || !this[0][0]) console.log('This function only works on 2 dimensional arrays!');
        for(let i=0; i<this.length; i++){
          if(this[i].sort().join(',') === array.sort().join(',')){
            return true
        return false;
    
  9. containsBy(elem, formatElem, formatListElem)
    Array.prototype.containsBy = function(elem, formatElem, formatListElem) {
        formatElem = formatElem || function (elem) {return elem;};
        formatListElem = formatListElem || function (elem) {return elem;};
        var contained = false;
        angular.forEach(this, function(listElem){
            if(formatListElem(listElem) == formatElem(elem)){
                contained = true;
        });
    ...