Created
May 30, 2018 07:50
-
-
Save micheleriva/929933eaa17f0a42fb863f00b625640d to your computer and use it in GitHub Desktop.
Simple example of boolean values for every JavaScript data type
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
// Booleans | |
Boolean(true) // => true | |
Boolean(false) // => false | |
// Strings | |
Boolean("foo") // => true | |
Boolean("") // => false | |
// Numbers | |
Boolean(1) // => true | |
Boolean(0) // => false | |
Boolean(1.5) // => true | |
Boolean(0.0) // => false | |
Boolean(NaN) // => false | |
// Objects | |
Boolean({}) // => true | |
Boolean([]) // => true | |
Boolean(null) // => false | |
// Undefined | |
Boolean(undefined) // => false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment