Concat vs Push

Benchmark created on


Setup

// Global setup
const array1 = [];
const array2 = [];
const elementsToAdd = 1000; // You can adjust this number as needed

// Populate the arrays
for (let i = 0; i < elementsToAdd; i++) {
    array1.push(i);
    array2.push(i + elementsToAdd);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Concat
array1.concat(array2);
ready
Push
array1.push(...array2);
ready

Revisions

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