Array extend

Benchmark created on


Setup

let arr1 = Array.from({ length: 1000 }, (_, i) => i+3);
const arr2 = Array.from({ length: 1000 }, (_, i) => i+3000);

Test runner

Ready to run.

Testing in
TestOps/sec
Concat
arr1 = arr1.concat(arr2);
ready
Spread
arr1.push(...arr2);
ready
for of
for (const e of arr2) {
	arr1.push(e);
}
ready
for loop by index
for (let i=0; i<arr2.length; i++) {
	arr1.push(arr2[i]);	
}
ready

Revisions

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