Skip to content

Instantly share code, notes, and snippets.

@kobeumut
Created October 24, 2017 07:47
Show Gist options
  • Save kobeumut/6062faa31c3f38eb0c9fbdb88448d603 to your computer and use it in GitHub Desktop.
Save kobeumut/6062faa31c3f38eb0c9fbdb88448d603 to your computer and use it in GitHub Desktop.
You can check your object is null or empty
var test = {};
if (test==null && isEmpty(test)) {
console.log("is empty");
} else {
console.log("is not empty");
}
function isEmpty(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key))
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment