Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Chrome 107
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
Using the spread operator 117915.7 Ops/sec
Using Array.prototype.concat 621934.0 Ops/sec
Script Preparation code:
x
 
var array1 = [];
var array2 = [];
for (let i = 0; i < 1000; i++) {
  array1[i] = Math.floor(Math.random() * 100);
  array2[i] = Math.floor(Math.random() * 100);
}
Tests:
  • Using the spread operator

     
    const array3 = [...array1, ...array2];
  • Using Array.prototype.concat

     
    const array3 = array1.concat(array2);