Nodejs Array Object Key containsProp(key,str)

Here you can find the source of containsProp(key,str)

Method Source Code

Array.prototype.containsProp = function(key,str) {
   var i = this.length,
      holder = [];//  w  ww .java 2  s.c  om
   while (i--) {
      if (this[i][key] === str) {
         holder.push(this[i]);
      }
   }
   return holder;
};

Related

  1. addIfUnique(key, value)
    Array.prototype.addIfUnique = function(key, value)
      if(this.contains(key))
        this[key] = value;
      else
        this.push(key);
        this[key] = value;
    
  2. by( key, id )
    Array.prototype.by = function( key, id )
      var index = this.length;
      while( index-- )
        if( this[ index ][ key ] == id ) {
          return this[ index ];
    };
    
  3. changeItem( key, property, value )
    Array.prototype.changeItem = function( key, property, value )
      var done = false;
        for(var i = 0; i < this.length; i++)
            if( this[i]["id"] == key)
              this[i][property] = value ; done = true;
        return done;
    };
    
  4. containsReturn(key, value)
    Array.prototype.containsReturn = function(key, value) {
        var i = this.length;
        while (i--) {
            if (this[i][key] === value){
                return i;
        return false;
    
  5. getKeys()
    Array.prototype.getKeys = function(){
      var keys = '';
      for(var i in this) keys += ',' + i;
      return keys.substr(1).split(',');
    
  6. hasKey()
    Array.prototype.hasKey = function(){ 
      for(i in this){ 
        if(i === arguments[0]) 
          return true; 
      }; 
      return false; 
    };
    
  7. hasMultipleByKey(key)
    Array.prototype.hasMultipleByKey = function(key) {
        var foundOnce = false;
        var i = this.length - 1;
        while (i >= 0) {
            if (this[i].getKey() === key) {
                if (foundOnce)
                    return true;
                else
                    foundOnce = true;
    ...