Primitives
Every value in JavaScript has a type. There are seven primitive types, but you’ll use five of them daily: strings, numbers, booleans,null, and undefined.
int vs float, no str vs bytes. JavaScript keeps it simpler than Python in this regard.
- JavaScript
- Python
null vs undefined
This is the one part that trips up Python developers. Python hasNone. JavaScript has two “nothing” values:
Type checking
Usetypeof to check what type a value is. This is especially useful when debugging or validating API responses.
Array.isArray():
Type coercion
JavaScript tries to be “helpful” by automatically converting types when you mix them. This leads to some genuinely weird behavior.+ operator is particularly tricky — if either side is a string, it concatenates instead of adding. The other math operators (-, *, /) convert strings to numbers.
Converting types explicitly
Values that convert to
false are called “falsy”: 0, "", null, undefined, NaN, and false. Everything else is “truthy.” You’ll use this concept constantly in React for conditional rendering.Equality: == vs ===
This is the most important syntax rule in this entire lesson.- JavaScript
- Python
Common mistakes
Using == instead of ===
Using == instead of ===
Confusing null and undefined
Confusing null and undefined
Assuming typeof null returns 'null'
Assuming typeof null returns 'null'
What’s next?
You know the building blocks — strings, numbers, booleans, and how to compare them safely. Next, let’s look at a cleaner way to work with strings using template literals.Template literals
String interpolation, multi-line strings, and goodbye to string concatenation