I'm sure there are some super awesome things you can do with reduce() but the examples given just seem to provide the same functionality as a foreach loop?
Is there a reduce() example you could give that could not be easily accomplished with a foreach or ends up being significantly more readable than the equivalent foreach loop? I'm primarily a php developer that is just getting into doing more serious javascript past basic jquery/dom stuff, so excuse me if I'm missing something.
I'm sure there are some super awesome things you can do with
reduce()
but the examples given just seem to provide the same functionality as aforeach
loop?Is there a
reduce()
example you could give that could not be easily accomplished with aforeach
or ends up being significantly more readable than the equivalentforeach
loop? I'm primarily a php developer that is just getting into doing more serious javascript past basic jquery/dom stuff, so excuse me if I'm missing something.It handles the object initialization for you, for one. Less typing, less bugs :)