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--) {
      var k = 0;
      for (var key in obj) {
         k++; 
      }
    }
  • Object.keys

     
    for (var i=10000; i > 0; i--) {
      Object.keys(obj).length;
    }
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: 3 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36
Chrome 91 on Linux
View result in a separate tab
Test name Executions per second
for-in 1284.5 Ops/sec
Object.keys 494.1 Ops/sec