foo in bar vs hasOwnProperty

Benchmark created by false on


Preparation HTML

<script>
  var Constructor = function() {},
      instance = new Constructor();
  Constructor.prototype.foo = 'bar';
  instance.baz = 'foo';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
foo in bar
'foo' in instance
ready
hasOwnProperty
instance.hasOwnProperty('foo')
ready

Revisions

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