push.apply vs concat

Benchmark created on


Setup

// Function using Array.push.apply()
function pushApply(arr1, arr2) {
    Array.prototype.push.apply(arr1, arr2);
    return arr1;
}

// Function using Array.concat()
function concatArrays(arr1, arr2) {
    return arr1.concat(arr2);
}

Test runner

Ready to run.

Testing in
TestOps/sec
pushApply
pushApply(new Array(100), new Array(100))
ready
concat
concatArrays(new Array(100), new Array(100))
ready

Revisions

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