Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Chrome 92
Windows
Desktop
3 years ago
Test name Executions per second
traditional for loop 18772.7 Ops/sec
for ... of 17825.6 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;
    }