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

     
    for (var i=10000; i > 0; i--) {
      for (var key in obj) {
          console.log(key); 
      }
    }
  • Object.keys

     
    for (var i=10000; i > 0; i--) {
      for (var 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 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
Chrome 84 on Mac OS X 10.15.6
View result in a separate tab
Test name Executions per second
for-in 1.1 Ops/sec
Object.keys 1.0 Ops/sec