check for property existance

Benchmark created on


Preparation HTML

<script>
  var o = {};
  var o2 = { bar: 'foo' };
  
  function countObj(o) {
  for ( var k in o ) {
      return true;
  }
  return false;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
o.keys.length
var c = Object.keys(o).length;
ready
o2.keys.length
var c = Object.keys(o2).length;
ready
o exit early
var c = countObj(o);
ready
o2 exit early
var c = countObj(o2);
ready

Revisions

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