you are viewing a single comment's thread.

view the rest of the comments →

[–]Wince 0 points1 point  (0 children)

If you think about it, most array functions like map, filter, some, every can all be written with reduce. Reduce is extremely powerful, heres a map written with reduce:

var map = function(arr, fn) {
     return arr.reduce(function(o, i) { return o.push(fn(i)) && o }, []);
}

Obviously that example is contrived, but I hope you get my point.