reduce with new array vs reduce with array mutation vs flatMap vs for vs for-of vs map vs forEach vs values (iterates over for-of)| Test case name | Result |
|---|---|
| reduce with new array | |
| reduce with array mutation | |
| flatMap | |
| for | |
| for-of | |
| map | |
| forEach | |
| values (iterates over for-of) |
| Test name | Executions per second |
|---|---|
| ✓ map | 27,197 Ops/sec |
| values (iterates over for-of) | 24,433 Ops/sec |
| for-of | 23,623 Ops/sec |
| forEach | 19,834 Ops/sec |
| reduce with array mutation | 19,090 Ops/sec |
| for | 782 Ops/sec |
| flatMap | 331 Ops/sec |
| reduce with new array | 7 Ops/sec |