Destructure vs Slice

Benchmark created on


Setup

const subject = Array.from({ length: 10_000 }).fill(0)

Test runner

Ready to run.

Testing in
TestOps/sec
Destructure
const copy = [...subject]

copy[0] = 1 

console.log(copy)
ready
Slice
const copy = subject.slice()

copy[0] = 1 

console.log(copy)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.