What’s a boolean in JavaScript?
Boolean types are represented as either true or false.
Examples of true Boolean types include:
1 // true
34 // true
-34 // true
-3245 // true
"this is true" // true
'this is false' // true
3 * 5 // true
Basically, anything with a value whether it’s positive or negative is considered true in Boolean eyes.
Examples of false Boolean types include:
0 // false
-0 // false
"" // false because its a string with nothing in it
undefined // false
null // false
NaN //false
false // false
Basically, anything without a value or has no value such as, “”, 0, or -0 is considered false. Also, anything that’s undefined, NaN, or null is considered false as well. And finally, anything that’s false is false.