Stage 2 · Lesson 1 of 10
Values, types and equality
has a few primitive : string, number, boolean, null, undefined, bigint and symbol. Everything else is an object, including arrays and functions. Declare variables with const by default, and with let when you must reassign.
Avoid var, which ignores . JavaScript converts between types silently, which is called coercion, and it causes most beginner surprises. "5" + 1 is "51", while "5" - 1 is 4.
The values 0, "", null, undefined and NaN all count as false in a condition, so they are called falsy. Always compare with ===, which checks type and value, not ==, which converts first. Use ?? to supply a default only for null or undefined, because || also replaces 0 and an empty string. Everything later in the stage assumes you can predict these results.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking JavaScript Fundamentals
Design Gurus · Beginner · $50
Guided beginner course on the language core, with quizzes after every chapter
- GuideFreeJavaScript.info
Ilya Kantor
Free and thorough: Part 1 for the language, Part 2 for the DOM and events, Part 3 for fetch
Practise
Keep handy
Also worth your time
- You Don't Know JS YetGo deeper
For when scope, this, coercion or async behaviour still feel like magic