Script Preparation code:
x
 
var testObj = {}
for (let i = 0; i < 10000; i++) {
  const randomString = Math.random().toString(36).substr(2, 5);
  testObj[randomString] = randomString;
}
Tests:
  • for in break

     
    let output;
    for (const key in testObj) {
      output = testObj[key];
      console.log(output);
      break;
    }
  • Object keys

     
    let output;
    output = Object.values(testObj)[0];
    console.log(output);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for in break
    Object keys

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
Chrome 86 on Windows
View result in a separate tab
Test name Executions per second
for in break 1283.1 Ops/sec
Object keys 457.4 Ops/sec