Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119
Windows
Desktop
one year ago
Test name Executions per second
unshift 1796.6 Ops/sec
push + reverse 1336.8 Ops/sec
Script Preparation code:
AخA
 
var arr = [10];
Tests:
  • unshift

     
    for (let i = 0; i < 10; i++){
      arr.unshift(i);
    }
  • push + reverse

     
    for (let i = 0; i < 10; i++){
      arr.push(i);
    }
    arr.reverse();