for-in-vs-object-keys-predicate

Benchmark created on


Setup

a=Object.create(null);
    b=Object.create(null);
    b.a=1;
    b.b=2;
    b.c=3;
    b.d=4;
    
    function forIn(y) {
      for (x in y) {
        return true;
      }
      return false;
    }
    
    function objectKeys(y) {
      return !!Object.keys(y).length;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
for-in
forIn(a);
forIn(b);
ready
keys
objectKeys(a);
objectKeys(b);
ready

Revisions

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