keys vs array (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script>
  var o = {};
  for (var i = 0; i < 1000; i++) {
    o[i] = i;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
keys
var a = Object.keys(o);
ready
arr
var a = [];
for (var k in o) {
  if (o.hasOwnProperty(k)) a.push[k];
}
ready
arr without test
var a = [];
for (var k in o) {
  a.push(k);
}
ready

Revisions

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