Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Chrome 129
Windows
Desktop
one year ago
Benchmark.js
`Array.slice(0, N)`
15.6M/s
`Array.length = N`
13.2M/s
`Object.assign([], arr)` with `Array.length = N`
406K/s
View exact numbers
Test name Executions per second
`Array.slice(0, N)` 15,604,940 Ops/sec
`Array.length = N` 13,238,485 Ops/sec
`Object.assign([], arr)` with `Array.length = N` 406,115 Ops/sec
Script Preparation code:
Tests: