Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Windows
Desktop
one year ago
Test name Executions per second
Spread 51575.7 Ops/sec
Concat 300218.8 Ops/sec
Concat from empty 225175.7 Ops/sec
Script Preparation code:
AخA
 
var a = Array.from({ length: 2000 }, (_, index) => index);
var b = Array.from({ length: 2000 }, (_, index) => 2000 - index);
Tests:
  • Spread

     
    const spread = [...a, ...b];
  • Concat

     
    const concat = a.concat(b);
  • Concat from empty

     
    const concatEmpty = [].concat(a).concat(b);