Shallow copy of an array

Benchmark created on


Description

Array.from vs. spread operator vs. structuredClone

Setup

const list = []
for (let i = 0; i < 3000; i++) {
  list.push({ label: String(i), value: i })
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array.from
const copy = Array.from(list)
ready
Spread operator
const copy = [...list]
ready
structuredClone
const copy = structuredClone(list)
ready

Revisions

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