Here’s_the_list of all of the falsy values:
- the Boolean value
false - the
nulltype - the
undefinedtype - the number
0 - the empty string
"" - the odd value
NaN(stands for "not a number", check out theNaNMDN article )
That's right, there are only_six_falsy values in all of JavaScript!
Here are some other examples of truthy values:
true
42
"pizza"
"0"
"null"
"undefined"
{}
[]
Ternary operator
Theternary operatorprovides you with a shortcut alternative for writing lengthy if...else statements.
conditional ? (if condition is true) : (if condition is false)
To use the ternary operator, first provide a conditional statement on the left-side of the?. Then, between the?and:write the code that would run if the condition istrueand on the right-hand side of the:write the code that would run if the condition isfalse.