Manuals / JavaScript / Chapter 2
A · Fundamentals · beginner · Week 1 · Chapter 2 of 14
Values, variables & control flow
JavaScript has eight types (seven primitives + object). let and const replace var. Control flow — if/else, loops, switch — is how programs make decisions. Master ===, truthy/falsy, and template literals before moving on.
Path progress9%
Step 1 of 5
Types and typeof
Primitives: string, number, boolean, null, undefined, symbol, bigint. Everything else is an object (including arrays and functions). typeof null returns "object" — a famous bug never fixed for compatibility.
Example
typeof "hello" // "string"
typeof 42 // "number"
typeof true // "boolean"
typeof undefined // "undefined"
typeof null // "object" (historical quirk)
typeof {} // "object"
typeof [] // "object"
typeof (() => {}) // "function"Do this now
In the console, test typeof on 10 different values. Write a comment explaining null and undefined.
Was this step clear?
Chapter learning outcomes
- Primitives vs objects
- let/const and block scope
- if/else, for, while
- === vs ==
- Template literals
Clear these before you leave
Side quest
FizzBuzz
Print 1–20. Multiples of 3 → "Fizz", 5 → "Buzz", both → "FizzBuzz". Use a loop and if/else.