Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/136.2 Mobile/15E148 Safari/605.1.15
Mobile Safari 18
iOS 18.3.2
Mobile
one month ago
Test name Executions per second
Array.push + Array.reverse 26669.9 Ops/sec
Array.unshift 97.0 Ops/sec
Script Preparation code:
AخA
 
const array = Array.from({length: 10_000}, () => Math.floor(Math.random() * 10_000_000))
Tests:
  • Array.push + Array.reverse

     
    const temp = [];
    array.forEach(x => temp.push(x));
    return temp.reverse();
  • Array.unshift

     
    const temp = [];
    array.forEach(x => temp.unshift(x));
    return temp;