Object keys iteration (v76)

Revision 76 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....

Preparation HTML

<script>
  var data = {};
  
  for (var i = 0; i < 100; i++) {
  
   data[i] =  { foo: 'bar ' + i, bar: null };
  
  }
  function ff(o,h){var i=0,k = Object.keys(o),l = k.length;while(i<l) {h(k[i++]);}}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for-each
Object.keys(data).forEach(function(key){data[key];});
ready
ff
ff(data,function(k){data[k];});
ready
for-in-no-hasOwnProperty
for (var key in data) {
  data[key];
}
ready
object-keys 3
var keys = Object.keys(data);
var len = keys.length;
var i;

for (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.