Nodejs Array Contain containsContentsOf(array)

Here you can find the source of containsContentsOf(array)

Method Source Code

Array.prototype.containsContentsOf = function(array) {
    var contains = true;
    if(!array)//from  w  ww .j  a  v a2s.c o m
        contains = false;

    for(var item=0; item<array.length; item++){
        if(this.indexOf(array[item]) < 0)
            contains = false;
    }

    return contains;
};

Related

  1. 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;
    
  2. 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;
    ...
    
  3. 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;
    
  4. 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;
        });
    ...
    
  5. containsByProp(propName, value)
    Array.prototype.containsByProp = function(propName, value){
      for (var i = this.length - 1; i > -1; i--) {
        var propObj = this[i];
          if(propObj[propName] === value) {
            return true;
    return false;
    
  6. containsDuplicateValues()
    Array.prototype.containsDuplicateValues = function () {
        var map = {};
        for (var i = 0, size = this.length; i < size; i++) {
            var value = this[i];
            if (value != 0) {
                if (map[value]) {
                    return true;
                map[value] = true;
    ...
    
  7. containsElementByProperty(chave,obj)
    Array.prototype.containsElementByProperty = function(chave,obj) {
        var i = this.length;
        while (i--) {
          if (angular.equals(this[i][chave], obj)) {
                return true;
        return false;
    };
    ...
    
  8. Contains( value )
    Array.prototype.Contains = function( value )
        for ( var i = 0; i < this.length; i++ )
            if ( this[ i ] === value ) return true;
        return false;
    };
    
  9. isContain(e)
    Array.prototype.isContain = function(e) {
      return this.indexOf(e) != -1;