Object membership check speed (v6)

Revision 6 of this benchmark created by Infinity on


Preparation HTML

<script>
  var obj = {
   'apples': 1,
   'bananas': 1
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
in keyword
if ('apples' in obj) {};

if ('not_here' in obj) {};

if ('bananas' in obj) {};
ready
dot syntax
if (obj.apples) {};

if (obj.not_here) {};

if (obj.bananas) {};
ready
array syntax
if (obj['apples']) {};

if (obj['not_here']) {};

if (obj['bananas']) {};
ready
hasOwnProperty
if (obj.hasOwnProperty('apples')) {};

if (obj.hasOwnProperty('not_here')) {};

if (obj.hasOwnProperty('bananas')) {};
ready

Revisions

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