Object keys iteration (v92)

Revision 92 of this benchmark created on


Description

Testing Object.keys vs for-in. I see that SlickGrid uses objects with indexed keys rather than arrays. Confused....

Setup

var data = {foo: 'bar', bar: null, d: 3, f: 20, g: 30};

Test runner

Ready to run.

Testing in
TestOps/sec
for-in
var ownProp = Object.prototype.hasOwnProperty;
for (var key in data) {
  if (ownProp.call(data, key)) {
    data[key];
  }
}
ready
for-in-cached-hasOwnProperty
var keys = Object.keys(data);
var len = keys.length;
for (var i = 0; i < len; ++i) {
  data[keys[i]];
}
ready

Revisions

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