values. But first, what are truthy and falsy values?
As the names suggest...
- Truthy expressions result in the boolean value true
- Falsy expressions result in the boolean value false
|If the boolean variable is set to be false, then it will evaluate to false.|
|If the value of the number is 0, then it will be considered as falsy.|
"" or ''
|If the string is blank (empty), then it will evaluate to false.|
|If a variable is declared but not assigned a value, then it will return a value called undefined and will also evaluate to false.|
|If the value is not a number, (e.g. divide a string by a number), then NaN (Not a Number) will be returned and will evaluate to false.|
** NOTE: Values other than the ones listed above are truthy values! **
Test it Out!
Go through each example below to see whether or not they will evaluate to false!
undefined Value (unassigned value):
NaN Value (invalid number):