99% of the time I see usage of Array.prototype.some and Array.prototype.reduce, it would have been much more readable with a manual loop.
How does #2 not use control Flow? It’s hidden in the implementation details of Array.some. Would the usage of Array.forEach somehow make it declarative because it hides the actual logic?
-
-
#2 is still locally functional, even if its dependency is not. At the end of the day the machine always does some mutation on some bits somewhere even when writing entirely pure code with entirely pure dependencies - but that doesn't make it non-functional.
-
I like mixed-purity languages that let me perform local "benign"/local mutations that aren't perceivable from the caller. JS can be used this way too.
- 3 more replies
New conversation -
-
-
Now you're triggering a discussion about Array.prototype.forEach. Personally, I consider .forEach an anti-pattern.
-
But .some might be implemented with flow control. But it needn't in a functional world. It might be implemented with recursion, too. That is, after all, the point of abstractions.
- 1 more reply
New conversation -
-
-
Notice that using Array.forEach requires very explicit side effects (using let, explicitly assigning value) so this would be even less pure than for .. of loop. Using lots of functions doesn't mean it's FP or declarative code
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.
he/him 