Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Firefox 135
Linux
Desktop
one year ago
Benchmark.js
`Array.length = N`
62.1M/s
`Array.slice(0, N)`
26.5M/s
`Object.assign([], arr)` with `Array.length = N`
664K/s
View exact numbers
Test name Executions per second
`Array.length = N` 62,108,124 Ops/sec
`Array.slice(0, N)` 26,477,164 Ops/sec
`Object.assign([], arr)` with `Array.length = N` 664,380 Ops/sec
Script Preparation code:
Tests: