Lesson 4 of 55
javascriptOperators & Expressions
9 mins
Course progress7%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 4 of 55
javascript9 mins
Keep these ideas in mind as you work through the lesson.
Arithmetic, comparison, logical, bitwise, assignment, and ternary operators.
| Operator | Example | Meaning |
|---|---|---|
+ - * / % | 5 * 2 | arithmetic |
=== !== | a === b | strict equality |
&& || | a && b | logical AND / OR |
?: | cond ? a : b | ternary (inline if) |
?? | a ?? b | nullish coalescing |
?. | obj?.prop | optional chaining |
let foo = 0;
console.log(foo || 42); // 42 (because 0 is falsy)
console.log(foo ?? 42); // 0 (nullish coalescing only for null/undefined)