Array.concat vs Array.slice vs For loop vs For loop with declared length vs While loop vs Spread operator vs Slice with begin argument vs Slice with begin and end argumentFastest: Slice with begin argument (47.8x faster)
91,431,088 ops/sec
87,552,624 ops/sec
60,654,792 ops/sec
54,130,476 ops/sec
24,002,996 ops/sec
2,152,768 ops/sec
2,111,465 ops/sec
1,914,440 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Array.concat | |
| Array.slice | |
| For loop | |
| For loop with declared length | |
| While loop | |
| Spread operator | |
| Slice with begin argument | |
| Slice with begin and end argument |
| Test name | Executions per second |
|---|---|
| ✓ Array.slice | 32,993,010 Ops/sec |
| Slice with begin argument | 32,890,174 Ops/sec |
| Slice with begin and end argument | 32,798,278 Ops/sec |
| Array.concat | 24,338,184 Ops/sec |
| While loop | 15,078,051 Ops/sec |
| For loop with declared length | 14,727,930 Ops/sec |
| For loop | 14,429,202 Ops/sec |
| Spread operator | 6,426,543 Ops/sec |