// Speed up calls to hasOwnProperty var hasOwnProperty = Object.prototype.hasOwnProperty;
functionisEmpty(obj) {
// null and undefined are "empty" if (obj == null) returntrue;
// Assume if it has a length property with a non-zero value // that that property is correct. if (obj.length > 0) returnfalse; if (obj.length === 0) returntrue;
// Otherwise, does it have any properties of its own? // Note that this doesn't handle // toString and valueOf enumeration bugs in IE < 9 for (var key in obj) { if (hasOwnProperty.call(obj, key)) returnfalse; }