2 ms·
I did a test at work. For a simple loop body, a for loop is much faster than .each. The reason is that function call is an expensive operation in Javascript.
by fsk 13y ago
I did a test at work. For a simple loop body, a for loop is much faster than .each. The reason is that function call is an expensive operation in Javascript.
- joelhooks 13y agoIf you're writing games or rich animated consumer facing solutions, by all mean scratch out that marginal perf boost. In reality, it hasn't been an issue. Trivial to profile and optimize where required/needed vs standardizing on verbose, up front, YAGNI performance gains. Lodash benchmarks must faster than underscore in a lot of areas, and addresses at least some of the perf issues while keeping the tasty sugar.