Created
February 17, 2022 11:48
-
-
Save marcelovani/e2b60d234bf5c21a73249da09b72a1f3 to your computer and use it in GitHub Desktop.
hasValue()
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
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