JavaScript
➗ Operators and coercion
JavaScript sometimes adds when you think it subtracts. Here you calculate, compare and combine values, and learn why it transforms types on its own so you don't fall into the trap.
What you'll learn
- Calculate with the arithmetic operators (
+,-,*,/,%,**) and update variables with shortcuts like+=and++. - Use the remainder
%to check parity and combine conditions with&&,||and!. - Tell
==apart from===and predict the result of a coercion like"5" + 1versus"5" - 1.
Lessons
Arithmetic and assignment operatorsAdd, subtract, multiply, powers, remainder and shortcuts like += and ++. Comparison and logical operators===, !==, <, >, and how to combine conditions with && || !. Type coercion: == vs ===Why "5" + 1 is "51" but "5" - 1 is 4.Practice this module in the app
DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.
Start free in the app →