Conditional Logic Flashcards
What are truthy and falsy values?
Truthy and falsy values are values which are not booleans, but are evaluated by JavaScript as booleans.
Ex: an empty string ''
evaluates to falsy.
What is the !!
operator?
The !!
(aka double-bang) operator first asseses a value as either truthy or falsy and returns a boolean of the opposite of that value’s truthiness or falsyness, and then converts that boolean to the actualt truthy or falsy boolean of the variable.
Whate are some examples of truthy values?
true
{}
[]
new Date()
'0'
42
What are some examples of falsy values?
false
null
undefined
0
NaN
''
What is the difference between the ==
operator and ===
operator?
The ==
operater compares loose equality, so 1 == '1'
is true; whereas, the ===
operator compares strict equality, so 1 === '1'
is false.
What is the Ternary Operator, and what is its syntax?
The ternary operator is a simplified if/else statement.
ex: number === 1 ? 'One' : 'No Match