Array.concat vs. spread

Benchmark created on


Description

Comparing merging two arrays via Array.concat versus spread

Setup

// Init two arrays with 10.000 entries each
const arr1 = Array.apply(null, Array(10000)).map(Number.prototype.valueOf,42);
const arr2 = Array.apply(null, Array(10000)).map(Number.prototype.valueOf,42);

Test runner

Ready to run.

Testing in WebKit 537.36 / undefined
TestOps/sec
Merging via Array.concat
const merged = arr1.concat(arr2);
ready
Merging via spread
const merged = [
  ...arr1,
  ...arr2,
];
ready

Revisions

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