hasOwnProperty call vs. direct

Benchmark created by Ken Snyder on


Description

Is it faster to call hasOwnProperty directly or via call? How much faster?

Preparation HTML

<script>
  var hash = {
   a: 1,
   b: 2,
   c: 3,
   d: 4,
   e: 5,
   f: 6
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty via call
for (var key in hash) {
 if (Object.prototype.hasOwnProperty.call(hash, key)) {
  hash[key] * 5;
 }
}
ready
in
for (var key in hash) {
 if (hash.hasOwnProperty(key)) {
  hash[key] * 5;
 }
}
ready

Revisions

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