Concat vs push 3

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Push
// Global setup
const array1 = [];
const elementsToAdd = 1000; // You can adjust this number as needed

// Populate the arrays
for (let i = 0; i < elementsToAdd; i++) {
    array1.push(...[i]);
}
ready
Concat
// Global setup
const array1 = [];
const elementsToAdd = 1000; // You can adjust this number as needed

// Populate the arrays
for (let i = 0; i < elementsToAdd; i++) {
    array1.concat([i]);
}
ready

Revisions

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