Skip to content

Instantly share code, notes, and snippets.

@marcelovani
Created February 17, 2022 11:48
Show Gist options
  • Save marcelovani/e2b60d234bf5c21a73249da09b72a1f3 to your computer and use it in GitHub Desktop.
Save marcelovani/e2b60d234bf5c21a73249da09b72a1f3 to your computer and use it in GitHub Desktop.
hasValue()
hasValue = function (value) {
if (typeof value === 'undefined') {
return false;
}
if (value === null) {
return false;
}
if (Object.prototype.hasOwnProperty.call(value, 'length') && value.length === 0) {
return false;
}
if (value.constructor === Object && Object.keys(value).length === 0) {
return false;
}
return Boolean(value);
};
exports default hasValue;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment