Appending multiple items to array

Benchmark created on


Setup

function genArrays() {
  let a1 = [];
  let a2 = [];
  for (let i = 0; i < 1000; i++) {
  	a1.push(Math.random());
  	a2.push(Math.random());
  }
  return {a1, a2}
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array.push(...items)
let {a1, a2} = genArrays();
a1.push(...a2);
ready
Array spread assignment
let {a1, a2} = genArrays();
a1 = [...a1, ...a2];
ready
Array.concat
let {a1, a2} = genArrays();
a1 = a1.concat(a2);
ready

Revisions

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