spread vs concat

Benchmark created on


Setup

const arrSize = 50;
const array1 = Array.from({ length: arrSize }, (_, i) => i);

const array2 = Array.from({ length: arrSize }, (_, i) => i + arrSize);

Test runner

Ready to run.

Testing in
TestOps/sec
spread
let array = [
  ...array1,
  ...array2,
];
ready
concat
let array = array1.concat(array2);
ready

Revisions

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