spread vs concat vs push

Benchmark created on


Setup

arr1 = Array.from(new Array(1000000), (_, i)=>i+1)
arr2 = Array.from(new Array(1000000), (_, i)=>i+2)
arr3 = Array.from(new Array(1000000), (_, i)=>i+2)

Test runner

Ready to run.

Testing in
TestOps/sec
spread
let res = [];
for (i=0;i<10; i++) {
	res = [...arr1, ...arr2, ...arr3];
}
ready
concat
let res = [];
for (i=0;i<10; i++) {
	res = res.concat(arr1).concat(arr2).concat(arr3);
}
ready

Revisions

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