loop over array (v4)

Revision 4 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 i = 0;

Object.keys(o).forEach(function (property) {
  i += o[property];
});
ready
arr
i = 0;

for (var property in o) {
 if (o.hasOwnProperty(property)) {
  i += o[property];
 }
}
ready

Revisions

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