Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
Firefox 96
Windows
Desktop
3 years ago
Test name Executions per second
forloop 43373.2 Ops/sec
for-of 36844.6 Ops/sec
forEach 42020.1 Ops/sec
Tests:
  • forloop

    AخA
     
    const array = [...Array(1000).keys()]
    for(let i = 0; i < array.length; i++) {
      const n = array[i];
    }
  • for-of

     
    const array = [...Array(1000).keys()]
    for(const n of array) {
      
    }
  • forEach

     
    const array = [...Array(1000).keys()]
    array.forEach(n => {});