Just remove the obj.hasOwnProperty filter:
function isEmpty(obj) { for (var prop in obj) { return false; } return true; }
That way, it will also tell you if there are any properties or something in the prototype chain, if you need it.
Alternatively you can change
if (obj.hasOwnProperty(prop))
to
if (!obj.hasOwnProperty(prop))
if you only want to know something is messing with a prototype with him.
source share