Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Safari 18
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
keyBy with for loop
46.4M/s
keyBy with native reduce
28.1M/s
keyBy with forEach
24.8M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with for loop
|
46,364,472 Ops/sec |
|
lodash/keyBy
|
38,477,928 Ops/sec |
|
keyBy with native reduce
|
28,113,750 Ops/sec |
|
keyBy with forEach
|
24,759,328 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop