Operators, Coercion and Equality
The rules behind every expression you write: what each operator does, the exact conversions JavaScript performs when types do not match, why == and === disagree, and how truthiness plus the nullish operators decide which default a value gets.
What you will be able to do
- Read any expression correctly using precedence and associativity
- Explain results like
1 + "1",[] + {}andtrue + truestep by step - Choose between
===,==,Object.isand a hand-writtendeepEqual - List the eight falsy values and say what is deliberately not on the list
- Pick
??over||whenever0,''orfalseis a legitimate value
Lessons
- The Operator Tour — An operator is a function with punctuation for a name, and precedence decides who gets the operands. (11 min)
- Type Coercion — When an operator needs a type it does not have, JavaScript runs a fixed conversion recipe. Learn the recipe and the surprises disappear. (13 min)
- Equality —
===asks "same type and same value".==asks the same question after converting, which is why it needs a rulebook. (11 min) - Truthiness and Defaults — Eight values are falsy. Everything else is truthy, including the empty containers people expect to be falsy. (12 min)