Is empty object (v3)

Revision 3 of this benchmark created on


Setup

let a = {
    "_id": "665dca588b2f662f07d327d6",
    "index": 4,
    "guid": "c0798c76-d4e9-494e-9b59-a22f980313ff",
    "isActive": true,
    "balance": "$3,732.87",
    "picture": "http://placehold.it/32x32",
    "age": 36,
    "eyeColor": "green",
    "name": "Bridget Burks",
    "gender": "female",
    "company": "AQUACINE",
    "email": "bridgetburks@aquacine.com",
    "phone": "+1 (803) 534-2241",
    "address": "639 Oliver Street, Finderne, Texas, 7987",
    "about": "Mi ",
    "registered": "2021-06-02T10:40:34 -02:00",
    "latitude": 45.290067,
    "longitude": 121.755408,
    "tags": [ 
    ],
    "friends": [ 
    ],
    "greeting": "Hello, Bridget Burks! You have 10 unread messages.",
    "favoriteFruit": "banana"
  };
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.