Skip to content

Instantly share code, notes, and snippets.

@aezell
Created November 28, 2012 16:14
Show Gist options
  • Save aezell/4162262 to your computer and use it in GitHub Desktop.
Save aezell/4162262 to your computer and use it in GitHub Desktop.
Is Javascript Object Empty?
// found here http://stackoverflow.com/a/2673229/64266
function isEmptyObject(obj) {
for(var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return false;
}
}
return true;
}
isEmptyObject({}); // true
isEmptyObject({foo:'bar'}); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment