Last active
October 24, 2018 18:04
-
-
Save Alex1990/4e018eea77ec9725403b to your computer and use it in GitHub Desktop.
Check if a value is truthy. The word "truthy" means the value is not one of undefined, null, false, 0, NaN or an empty string "".
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
// Check if a value is truthy. The word truthy means the value is not one of undefined, null, false, 0, NaN or an empty string "". | |
// Also, you can use the Boolean function to convert the value. | |
function isTruthy(o) { | |
return !!o; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"0" should be true. Cast to a number if you want to test for 0