Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Chrome 136
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
`Array.slice(0, N)`
44.8M/s
`Array.length = N`
36.2M/s
`Object.assign([], arr)` with `Array.length = N`
680K/s
View exact numbers
Test name Executions per second
`Array.slice(0, N)` 44,807,736 Ops/sec
`Array.length = N` 36,174,528 Ops/sec
`Object.assign([], arr)` with `Array.length = N` 679,703 Ops/sec
Script Preparation code:
Tests: