Javascript Array inject(memo, iterator, context)
Array.prototype.inject = function(memo, iterator, context) { this.each(function(value, index) { memo = iterator.call(context, memo, value, index); });//from www.jav a2s . co m return memo; }