Script Preparation code:
AخA
 
var array = new Array(100);
for (let i = 0; i < 100; i++) {
  array[i] = i * i;
}
Tests:
  • for

     
    let sum = 0
    for (let i = 0, l = array.length; i < l; i++) {
      sum += array[i];
    }
  • foreach

     
    let sum = 0;
    array.forEach(function(i) {
      sum += array[i];
    });
  • for in

     
    let sum = 0;
    for (var i in array) {
      sum += array[i];
    }
  • for..of

     
    let sum = 0;
    for (var i of array) {
      sum += array[i];
    }
  • reduce

     
    array.reduce((a, b) => a + b, 0);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for
    foreach
    for in
    for..of
    reduce

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1
Mobile Safari 17 on iOS 17.6.1
View result in a separate tab
Test name Executions per second
for 337955.8 Ops/sec
foreach 225454.9 Ops/sec
for in 234273.3 Ops/sec
for..of 236524.2 Ops/sec
reduce 6406056.0 Ops/sec