concat vs spread

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
concat
const arr1 = [1,2,3,4,5];
const arr2 = [6,7,8,9,10];
const newArr = arr1.concat(arr2);
ready
spread
const arr1 = [1,2,3,4,5];
const arr2 = [6,7,8,9,10];
const newArr = [...arr1, ...arr2];
ready
push
const arr1 = [1,2,3,4,5];
const arr2 = [6,7,8,9,10];
const newArr = []
newArr.push(...arr1,...arr2);
ready
flat
const arr1 = [1,2,3,4,5];
const arr2 = [6,7,8,9,10];
const newArr = [arr1,arr2].flat();
ready

Revisions

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