Script Preparation code:
AخA
 
var arr = [12342, 342, 3423, 432, 432, 423, 43, 3, 1, 321, 323, 1, 31, 31, 31, 231, 31, 31];
Tests:
  • for..of

     
    const narr = [];
    for(const item of arr){
      narr.push(item)
    }
  • for..in

     
    const narr = [];
    for(const item in arr){
      narr.push(arr[item])
    }
  • for

     
    const narr = [];
    for(let i=0; i<arr.length; i++){
      narr.push(arr[i])
    }
  • foreach

     
    const narr = [];
    arr.forEach( e => narr.push(e));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

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

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Chrome 116 on Linux
View result in a separate tab
Test name Executions per second
for..of 6972662.5 Ops/sec
for..in 652810.6 Ops/sec
for 530400.2 Ops/sec
foreach 6908423.0 Ops/sec