merge-array implementations (v5)

Revision 5 of this benchmark created on


Setup

var arr1 = Array.from(Array(10000), (x,i) => i + 1)
var arr2 = Array.from(Array(10000), (x,i) => i - 1)  
var arr1Length = arr1.length; 
var arr2Length = arr2.length;

Test runner

Ready to run.

Testing in
TestOps/sec
concat
arr1 = arr1.concat(arr2)
ready
spread
arr1 = [...arr1, ...arr2]
ready
native add
for(var i = 0; i < arr2; i++){
 arr1[arr1Length + i] = arr2[i]
}
ready
for each push back
arr2.forEach((element) => arr1.push(element));
ready

Revisions

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