Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0
Firefox 93
Ubuntu
Desktop
3 years ago
Test name Executions per second
slice 11879.8 Ops/sec
push-apply 6931.0 Ops/sec
the ...operator 2230.7 Ops/sec
for-push 2406.2 Ops/sec
concat 3903.3 Ops/sec
Script Preparation code:
AخA
 
arr0 = [];
for(var i=0;i<10000;i++){
  arr0.push("var "+i);
}
Tests:
  • slice

     
    var other = arr0.slice()
  • push-apply

     
    var other = [];
    Array.prototype.push.apply(other, arr0);
  • the ...operator

     
    var other = [...arr0];
  • for-push

     
    var other = [];
    for(var i=0;i<arr0.length;i++){
      other.push(arr0[i]);
    }
  • concat

     
    var other = [];
    other = other.concat(arr0);