Is empty object

Benchmark created on


Setup

let a = {
	"a": 0,
	"b": 0,
	"c": 0,
	"d": 0,
}
function isEmptyObject(object ) {
  for (const key in object) {
    if (Object.prototype.hasOwnProperty.call(object, key)) {
      return false;
    }
  }

  return true;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Object.keys
let c = Object.keys(a).length > 0;
ready
for .. in
let c = isEmptyObject(a);
ready

Revisions

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