Script Preparation code:
Tests:

Historical Performance Data aggregated from 22 community runs

Desktop Results:
Chrome 22 runs
`Array.slice(0, N)`
12.8M/s
`Array.length = N`
10.9M/s
`Object.assign([], arr)` with `Array.length = N`
296K/s

Fastest: `Array.slice(0, N)` (43.1x faster)

View exact numbers
  • `Array.slice(0, N)`: 12,772,138 ops/sec
  • `Array.length = N`: 10,928,885 ops/sec
  • `Object.assign([], arr)` with `Array.length = N`: 296,281 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    `Array.slice(0, N)`
    `Array.length = N`
    `Object.assign([], arr)` with `Array.length = N`

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Chrome 137 on Windows
View result in a separate tab
`Array.slice(0, N)`
23.6M/s
`Array.length = N`
20.4M/s
`Object.assign([], arr)` with `Array.length = N`
231K/s
View exact numbers
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