Created
November 28, 2012 16:14
-
-
Save aezell/4162262 to your computer and use it in GitHub Desktop.
Is Javascript Object Empty?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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