Comment

Comment by FlameWolf

In my case, it's more of a personal preference than any measurable impact. Practically, `for...of` would be the best approach. But I like to avoid chaining and avoid manually building an array (in your example I'd replace `acc.push(el * 2);` with `return acc.concat(el * 2);` -- even though I suspect `push` might be more performant but not sure). Why do I prefer it? Can't explain. If the nanoseconds really mattered then I might change it. Otherwise it's just one of the many ways of achieving the same goal.
parent FlameWolf 1 month ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton