List of utility methods to do Array Value
aggregate(initialValue, aggregateItemCallback)Array.prototype.aggregate = function (initialValue, aggregateItemCallback) { var result = initialValue; this.each(function (item) { result = aggregateItemCallback(result, item); }) return result; | |
allValuesSame()Array.prototype.allValuesSame = function() { for(var i = 1; i < this.length; i++) if(this[i] !== this[0]) return false; return true; | |
allValuesSame()Array.prototype.allValuesSame = function() { for(var i = 1; i < this.length; i++) if(this[i] !== this[0]) return false; return true; | |
allValuesSame()var canvas = {}; Array.prototype.allValuesSame = function() { for(var i = 1; i < this.length; i++) { if(this[i] !== this[0]) return false; return true; | |
byField(field, value)Array.prototype.byField = function(field, value) { return this.filter(function ( obj ) { return obj[field] == value; })[0] | |
defaultIfEmpty(val)Array.prototype.defaultIfEmpty = function (val) { return this.length == 0 ? [val == null ? null : val] : this; }; | |
elementWithAttr(attr, value)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; }; | |
first(attribut, value)Array.prototype.first = function (attribut, value) { for (var i = 0; i < this.length; i++) { if (this[i][attribut] == value) return this.slice(i, i + 1)[0]; return null; }; | |
getNextValue(index)Array.prototype.getNextValue = function(index) { let nextIndex = index + 1; if(nextIndex < this.length) { return this[nextIndex]; return null; | |
hasWhere(property, value)Array.prototype.hasWhere = function (property, value) { "use strict"; for(var i = 0; i < this.length; i++) { if(this[i][property] === value) { return true; return false; }; ... |