Spread vs concat vs push for new array copy

Benchmark created on


Setup

const array = Array.from({length: 1000}).map((_, i) => i);

Test runner

Ready to run.

Testing in
TestOps/sec
Spread
const newArr = [...array];
ready
Concat
const newArr = array.concat();
ready
Push spread
const newArr = [];
newArr.push(...array);
ready

Revisions

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