Running the microbenchmark produces
$ npm run benchmark
> @ benchmark .../lodash-each-microbenchmark
> node index.js
withForLoop x 2,291,112 ops/sec ±1.78% (87 runs sampled)
withLodash x 732,795 ops/sec ±1.34% (85 runs sampled)
The comparison is between just a vanilla for
loop
for (const value of VALUES) {
result.push(value * value);
}
and using _.each
_.each(VALUES, value => {
result.push(value * value);
});
See also a jsPerf with a similar test.