|
|
|
|
|
by dandare
1606 days ago
|
|
You made two mistakes: You optimise prematurely and your assumption is incorrect. Premature optimisation: In most cases the performance would not matter. Instead of optimising for performance you should optimise for readability. IMHO IFs and FORs are way more readable in any context than any language specific methods like REDUCE and MAX. Incorrect optimisation: At least in modern browsers, simple IFs and FORs are the most optimised methods of doing anything. See for instance https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_... (Operations per second, higher is better). |
|
The idea that “reduce” is language specific is frankly mind boggling. It’s no more language specific than a loop.