Script Preparation code:
AخA
 
var object = {}
var array = []
for (var i = 0; i < 10000; i++) {
  object[i] = { id: i }
  array[i] = { id : i }
}
Tests:
  • for in

     
    for (var x in object) { console.log(x, object[x]) }
  • forEach

     
    array.forEach(function(x, y) { console.log(y, x) })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for in
    forEach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0
Firefox 90 on Ubuntu
View result in a separate tab
Test name Executions per second
for in 2.5 Ops/sec
forEach 2.6 Ops/sec