Push item to an array vs Append an item by spread vs Direct assign an item to an initialized arrayFastest: Push item to an array (9.9x faster)
14,020 ops/sec
13,949 ops/sec
1,423 ops/sec
Fastest: Direct assign an item to an initialized array (29.2x faster)
21,701 ops/sec
20,978 ops/sec
744 ops/sec
Fastest: Push item to an array (1256.3x faster)
592,950 ops/sec
552,680 ops/sec
472 ops/sec
Fastest: Direct assign an item to an initialized array (11.6x faster)
8,180 ops/sec
8,004 ops/sec
706 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Push item to an array | |
| Append an item by spread | |
| Direct assign an item to an initialized array |
| Test name | Executions per second |
|---|---|
| ✓ Direct assign an item to an initialized array | 510,815 Ops/sec |
| Push item to an array | 228,925 Ops/sec |
| Append an item by spread | 1,422 Ops/sec |