Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Mac OS X 10.15.7
Desktop
6 months ago
Test name Executions per second
slice 18647696.0 Ops/sec
push 4287220.5 Ops/sec
Script Preparation code:
AخA
 
var data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
Tests:
  • slice

     
    var copy = data.slice(3, 8);
  • push

     
    var copy = [];
    for (var i = 3; i < 8; i++) {
      copy.push(data[i])
    }