2 ms·
I primarily program in JavaScript and between Lodash and the built in iterator functions I don't see any reason to use loops other than the while loop. I often
by harimau777 7y ago
I primarily program in JavaScript and between Lodash and the built in iterator functions I don't see any reason to use loops other than the while loop.
I often use recursion rather than while loops; however, I find that is often difficult to do in a way that is readable and that uses tail recursion.
What I really wish is that something like "forUntil", "mapUntil", and "reduceUntil" would be added to the core language. Maybe the forEach, map, and reduce could be made generic functions that operated on any iterable rather than being defined as methods of Array.