concat vs push

Benchmark created on


Setup

var arr1 = [];
var arr2 = [];
for (i=0; i<15000; i++) {
	arr1.push(i+'');
	arr2.push(i*2+'');
}

Test runner

Ready to run.

Testing in
TestOps/sec
concat
var arr3 = arr1.concat(arr2);
ready
push
var arr3 = arr2.forEach(function(element){
	arr1.push(element);
})
ready
spread
var arr3 = arr1.push(...arr2);
ready
apply
var arr3 = Array.prototype.push.apply(arr1, arr2);
ready

Revisions

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