Here’s_the_list of all of the falsy values:

  1. the Boolean value false
  2. the null type
  3. the undefined type
  4. the number 0
  5. the empty string ""
  6. the odd value NaN (stands for "not a number", check out the NaNMDN 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.

results matching ""

    No results matching ""