Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Chrome 92
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
traditional for loop 31345.6 Ops/sec
for ... of 32963.2 Ops/sec
Tests:
  • traditional for loop

    x
     
    const arr = Array(10000).fill(1);
    let sum = 0;
    for (let i = 0; i < arr.length; i++) {
      sum += i;
    }
  • for ... of

     
    const arr = Array(10000).fill(1);
    let sum = 0;
    for (const el of arr) {
      sum += el;
    }