my rule for .reduce(): only use it when the result has the same type as the items and the reducer is associative, like
.reduce((a, b) => a + b, 0)
summing some numbers
multiplying some numbers
building up a list or object
just about anything else (use a loop)
A sufficiently smart compiler, etc. It sounds complicated to get right, though, and this does not seem like a very common/idiomatic pattern (?).
-
-
Now you've got me wondering how to measure it. My hypothesis is that reduce is an advanced feature, so not as popular. Of those who use it, many create garbage on every iteration that could be optimized away. Not sure what the real world consequences of that garbage are.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.