Sure i can do:
var obj = {};
if(Object.keys(obj).length == 0)
but i was curious if there is a way to say:
var obj = {};
if(obj.hasKeys())
or even:
//already tested, and this doesnt work. its true because it *is* something.
var obj = {};
if(!obj)
function hasKeys(o) {
for (var name in o)
if (o.hasOwnProperty(name))
return true;
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With