hasOwnProperty vs. in

Benchmark created by Kim Trott 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

Revisions

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