Conditional Logic Flashcards

1
Q

What are truthy and falsy values?

A

Truthy and falsy values are values which are not booleans, but are evaluated by JavaScript as booleans.

Ex: an empty string '' evaluates to falsy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the !! operator?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Whate are some examples of truthy values?

A
  • true
  • {}
  • []
  • new Date()
  • '0'
  • 42
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are some examples of falsy values?

A
  • false
  • null
  • undefined
  • 0
  • NaN
  • ''
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between the == operator and === operator?

A

The == operater compares loose equality, so 1 == '1' is true; whereas, the === operator compares strict equality, so 1 === '1' is false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Ternary Operator, and what is its syntax?

A

The ternary operator is a simplified if/else statement.

ex: number === 1 ? 'One' : 'No Match

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly