Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2012 21:03
What would you like to do?
JavaScript Array Reduce Function
Array.prototype.reduce = function (fn, init) {
var s = init;
var l = this.length;
for (var i = 0; i < l; i++) {
s = fn(s, this[i]);
return s;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment