Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127
Windows
Desktop
2 years ago
Benchmark.js
`Array.slice(0, N)`
9.8M/s
`Array.length = N`
6.2M/s
`Object.assign([], arr)` with `Array.length = N`
203K/s
View exact numbers
Test name Executions per second
`Array.slice(0, N)` 9,816,005 Ops/sec
`Array.length = N` 6,203,298 Ops/sec
`Object.assign([], arr)` with `Array.length = N` 203,393 Ops/sec
Script Preparation code:
Tests: