Object Keys Vs For In (v9)

Revision 9 of this benchmark created by QJ on


Setup

var jsonObj = {}
    for (var i = 0; i < 50000; i++) jsonObj[i] = i;

Test runner

Ready to run.

Testing in
TestOps/sec
Object.keys
Object.keys(jsonObj).forEach(function(k) {
  var v = jsonObj[k];
})
ready
For In
for (var k in jsonObj) {
  var v = jsonObj[k];
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.