.filter().map() vs .flatMap() vs .reduce() vs for ... of vs regular for vs regular for, prefilled then trimmedFastest: for ... of (13.7x faster)
7,950 ops/sec
2,653 ops/sec
2,495 ops/sec
1,323 ops/sec
1,171 ops/sec
579 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| .filter().map() | |
| .flatMap() | |
| .reduce() | |
| for ... of | |
| regular for | |
| regular for, prefilled then trimmed |
| Test name | Executions per second |
|---|---|
| ✓ for ... of | 4,897 Ops/sec |
| regular for | 1,268 Ops/sec |
| .reduce() | 1,165 Ops/sec |
| .filter().map() | 668 Ops/sec |
| .flatMap() | 586 Ops/sec |
| regular for, prefilled then trimmed | 255 Ops/sec |