Array Concat vs Spread

Benchmark created by mturnwall on


Setup

const arr1 = [30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9];
  const arr2 = [30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9];
  const arr3 = [30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9];
  const arr4 = [30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9, 30, 20, 15, 12, 9];

Test runner

Ready to run.

Testing in
TestOps/sec
Concat
let combinedArr = arr1.concat(arr2, arr3, arr4);
ready
Spread
let combinedArr = [...arr1, ...arr2, ...arr3, ...arr4];
ready

Revisions

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

  • Revision 1: published by mturnwall on