Nodejs Array Object Key hasMultipleByKey(key)

Here you can find the source of hasMultipleByKey(key)

Method Source Code

Array.prototype.hasMultipleByKey = function(key) {
    var foundOnce = false;
    /*from  w ww. j  a v a2  s  .  co  m*/
    var i = this.length - 1;
    while (i >= 0) {
        if (this[i].getKey() === key) {
            if (foundOnce)
                return true;
            else
                foundOnce = true;
        }
        i--;
    }
    
    return false;
};

Related

  1. 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;
    };
    
  2. containsProp(key,str)
    Array.prototype.containsProp = function(key,str) {
      var i = this.length,
        holder = [];
      while (i--) {
        if (this[i][key] === str) {
          holder.push(this[i]);
      return holder;
    ...
    
  3. containsReturn(key, value)
    Array.prototype.containsReturn = function(key, value) {
        var i = this.length;
        while (i--) {
            if (this[i][key] === value){
                return i;
        return false;
    
  4. getKeys()
    Array.prototype.getKeys = function(){
      var keys = '';
      for(var i in this) keys += ',' + i;
      return keys.substr(1).split(',');
    
  5. hasKey()
    Array.prototype.hasKey = function(){ 
      for(i in this){ 
        if(i === arguments[0]) 
          return true; 
      }; 
      return false; 
    };
    
  6. keys()
    Array.prototype.keys = function keys () {
      return new ArrayIterator(this, 'key');
    };
    
  7. notIn( key, array )
    Array.prototype.notIn = function( key, array )
        return this.filter( function(element)
            var flag = true;
            for(var i = 0; i < array.length; i++)
                if( element[key] == array[i][key]) flag = false;
            return flag;
        });
    };
    
  8. objectIndex(key,value)
    Array.prototype.objectIndex = function(key,value) {
      for(var i = 0, len = this.length; i < len; i++) {
          if (this[i][key] === value) return i;
      return -1;
    
  9. options(textKey, valueKey)
    Array.prototype.options = function(textKey, valueKey) {
      var options = [];
      options = this.map(function(item) {
         return { text: item[textKey], value: item[valueKey] }
      });
      return options;