This blog post explains how the index works that Array.prototype.reduce() passes to its callback.
> var a = [ 'a', 'b', 'c' ]; > a.reduce(function(x, y, i) { console.log(i) }); 1 2 > a.reduce(function(x, y, i) { console.log(i) }, 0); 0 1 2It does make sense if you look at the signature of the reduce() callback:
function (previousValue, currentElement, currentIndex, array)Therefore, what is logged in the example is the index of y.
> function add(prev, cur) { return prev + cur } undefined > [].reduce(add) TypeError: Reduce of empty array with no initial value > [].reduce(add, 123) 123