Script Preparation code:
AخA
 
var existing = [ 1, 2, "hello", true, 7 ];
var newi = 1;
Tests:
  • Array.prototype.concat

     
    var other = existing.concat([newi]);
  • spread operator

     
    var other = [ ...existing, newi ];
  • copy on push

     
    var other = existing.concat().push(newi);
  • directly push

     
    existing.push(newi);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.prototype.concat
    spread operator
    copy on push
    directly push

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15
Safari 16 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Array.prototype.concat 10465505.0 Ops/sec
spread operator 10813093.0 Ops/sec
copy on push 6784341.0 Ops/sec
directly push 14048991.0 Ops/sec