form-cheatsheet/js/polyfills/EcmaScript/Array.prototype.reduce.js

2 lines
479 B
JavaScript

Array.prototype.reduce=function(d){if(!this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!==typeof d)throw new TypeError(d+" is not a function");var b=Object(this),e=b.length>>>0,a=0,c;if(2==arguments.length)c=arguments[1];else{for(;a<e&&!(a in b);)a++;if(a>=e)throw new TypeError("Reduce of empty array with no initial value");c=b[a++]}for(;a<e;a++)a in b&&(c=d(c,b[a],a,b));return c};
//# sourceMappingURL=Array.prototype.reduce.js.map