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 aforeachloop?Is there a
reduce()example you could give that could not be easily accomplished with aforeachor ends up being significantly more readable than the equivalentforeachloop? 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 :)