isEmpty using Object.keys vs. hasOwnProperty (v16)

Revision 16 of this benchmark created on


Setup

var i;
    var key;
    var keys;
    var l;
    var value;
    var hasOwnProperty = {}.hasOwnProperty;
    var obj = {
      'a': 1,
      'b': 2,
      'c': 3,
      'd': 4,
      'e': 5,
      'f': 6,
      'g': 7,
      'h': 8,
      'i': 9,
      'j': 10
    };

Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
for (key in obj) {
  if (hasOwnProperty.call(obj, key)) {
    break;
  }
}
ready
Object.keys
var result = Object.keys(obj).length > 0;
ready

Revisions

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