Here you can find the source of allValuesSame()
//Add some useful functions to the array prototype Array.prototype.allValuesSame = function() { for(var i = 1; i < this.length; i++) {// w w w. j a va2 s . co m if(this[i] !== this[0]) return false; } return true; }
Array.prototype.aggregate = function (initialValue, aggregateItemCallback) { var result = initialValue; this.each(function (item) { result = aggregateItemCallback(result, item); }) return result;
Array.prototype.allValuesSame = function() { for(var i = 1; i < this.length; i++) if(this[i] !== this[0]) return false; return true;
var canvas = {}; Array.prototype.allValuesSame = function() { for(var i = 1; i < this.length; i++) { if(this[i] !== this[0]) return false; return true;
Array.prototype.byField = function(field, value) { return this.filter(function ( obj ) { return obj[field] == value; })[0]
Array.prototype.defaultIfEmpty = function (val) { return this.length == 0 ? [val == null ? null : val] : this; };
Array.prototype.elementWithAttr = function (attr, value) { for(var i = 0; i < this.length; i += 1) { if(this[i][attr] === value) { return this[i]; return null; };