Run details:
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
Windows
Desktop
one year ago
Benchmark.js
`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
Script Preparation code:
Tests: