`Array.slice(0, N)` vs `Array.length = N` vs `Object.assign([], arr)` with `Array.length = N`Fastest: `Array.slice(0, N)` (43.1x faster)
12,772,138 ops/sec
10,928,885 ops/sec
296,281 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| `Array.slice(0, N)` | |
| `Array.length = N` | |
| `Object.assign([], arr)` with `Array.length = N` |
| Test name | Executions per second |
|---|---|
| ✓ `Array.slice(0, N)` | 23,557,978 Ops/sec |
| `Array.length = N` | 20,357,434 Ops/sec |
| `Object.assign([], arr)` with `Array.length = N` | 231,196 Ops/sec |