Script Preparation code:
AخA
 
var object = {};
  
for (let i = 0; i < 1000; i += 1) {
  object['something' + i] = 'value';
}
Tests:
  • forEach

     
    Object.entries(object).forEach(([key, value]) => {
        console.log(key, value);
    });
  • for of

     
    for (const [key, value] of Object.entries(object)) {
        console.log(key, value);
    }
  • traditional for loop

     
    for (let i = 0; i < Object.keys(object); i += 1) {
        console.log(Object.keys(object)[i], value);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    forEach
    for of
    traditional for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Chrome 107 on Windows
View result in a separate tab
Test name Executions per second
forEach 247.4 Ops/sec
for of 219.9 Ops/sec
traditional for loop 13384.1 Ops/sec