This will detect enumerable properties, and inherit fromObject.prototype , as your example:
Object.defineProperty(Object.prototype, "hasKeys", {
configurable: true,
value: function() {
for (var _ in this) return true;
return false;
}
});
To detect non-enumerable properties, you will need to use Object.getOwnPropertyNames.
Bergi source
share