Script Preparation code:
AخA
 
var obj = {
  'a': 1,
  'b': 2,
  'c': 3,
  'd': 4,
  'e': 5,
  'f': 6,
  'g': 7
};
Tests:
  • for-in

     
    for (let i = 0; i < 10000; ++i) {
      for (const key in obj) {
          console.log(key); 
      }
    }
  • Object.keys

     
    for (let i = 0; i < 10000; ++i) {
      for (const key of Object.keys(obj)) {
        console.log(key);
      }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for-in
    Object.keys

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
Chrome 89 on Linux
View result in a separate tab
Test name Executions per second
for-in 1.4 Ops/sec
Object.keys 0.9 Ops/sec