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 (37.0x faster)
3,766,500 ops/sec
3,627,908 ops/sec
3,589,992 ops/sec
3,428,044 ops/sec
2,450,696 ops/sec
154,476 ops/sec
148,564 ops/sec
101,931 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 |
|---|---|
| ✓ Slice with begin argument | 3,431,886 Ops/sec |
| Spread operator | 3,327,696 Ops/sec |
| Array.concat | 3,315,430 Ops/sec |
| Array.slice | 3,300,158 Ops/sec |
| Slice with begin and end argument | 2,225,193 Ops/sec |
| While loop | 138,394 Ops/sec |
| For loop with declared length | 129,563 Ops/sec |
| For loop | 92,926 Ops/sec |