hasOwnProperty vs. in (v5)

Revision 5 of this benchmark created by andrius on


Description

Compare hasOwnProperty to in check

Preparation HTML

<script>
  var iter = 100,
      testObj = {};
  
  for (var i = 0; i < iter; i++) {
   testObj["foo" + i] = i;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
testObj.hasOwnProperty("foo50");
ready
in check
"foo50" in testObj;
ready
hasOwnProperty falsy
testObj.hasOwnProperty("foo200");
ready
in falsy
"foo200" in testObj;
ready

Revisions

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