Nodejs Array Value allValuesSame()

Here you can find the source of allValuesSame()

Method Source Code

Array.prototype.allValuesSame = function() {
    for(var i = 1; i < this.length; i++)
    {/*from w  w w.ja v  a  2s . c om*/
        if(this[i] !== this[0])
            return false;
    }

    return true;
}

Related

  1. aggregate(initialValue, aggregateItemCallback)
    Array.prototype.aggregate = function (initialValue, aggregateItemCallback) {
      var result = initialValue; 
      this.each(function (item) {
        result = aggregateItemCallback(result, item);
      })
      return result;
    
  2. allValuesSame()
    Array.prototype.allValuesSame = function() {
      for(var i = 1; i < this.length; i++)
        if(this[i] !== this[0])
          return false;
      return true;
    
  3. allValuesSame()
    var canvas = {};
    Array.prototype.allValuesSame = function() {
      for(var i = 1; i < this.length; i++) {
          if(this[i] !== this[0])
              return false;
      return true;
    
  4. byField(field, value)
    Array.prototype.byField = function(field, value) {
      return this.filter(function ( obj ) {
        return obj[field] == value;
      })[0]
    
  5. defaultIfEmpty(val)
    Array.prototype.defaultIfEmpty = function (val) {
      return this.length == 0 ? [val == null ? null : val] : this;
    };