Values & Variables
foundation — everything stands on thisThe big question: “What happens in memory when I create a variable?”
Try to imagine a program that can’t remember. You type your name into an app — and one instruction later, it’s gone. A game where the score can’t be kept. A shopping cart that forgets each item the moment you add the next. Useless, right? Programs are only useful because they can hold on to things while they work.
A variable IS that remembering. And it gives the remembered thing a name, so later instructions can talk about it: “add the price to the total” only works because price and total are names pointing at stored values. Every username on a screen, every score, every cart total you have ever seen was a variable in someone’s program.
This is the foundation everything else stands on. Every app you’ve ever used — WhatsApp, YouTube, a bank app — is at its core just values being remembered and changed. A value is one piece of data: the number 25, the text "hello", the answer true.
A variable is how a program remembers a value: the machine reserves one of its memory boxes, puts the value inside, and ties a name to the box — like a label on a jar. From then on, using the name means “go look in that jar.” That’s it. That’s the big secret.
Take this phase slowly. If variables, values, and types become truly obvious to you, every later phase gets easier — functions, objects, even Playwright tests are all built from these same jars.
One piece of data: 25, "hello", or true.
A named memory box holding one value, so the program can use it later by name.
Creating the variable — “machine, reserve a box and call it age.”
Putting a value into the box. The = sign means “put this in”, NOT “equals”.
What kind of value something is: number, text (string), true/false (boolean)… The kind decides what you can do with it.
undefined = “nobody ever put anything in this box.” null = “someone deliberately put nothing in it.”
- ✓Create a variable and draw what happened in memory
- ✓Explain why changing a variable doesn’t move its label
- ✓Name the basic types and check one with typeof
- ✓Predict tricky results like "5" + 5 — and explain why
Watch a variable being born
A taste of lesson 1.2. Step through with the buttons or ← → keys — go backward any time.
let age = 25; age = 26;
One line of code: let age = 25. In English it means “machine, please remember the number 25, and call it age.” Let’s watch the machine actually do it.
- 1.1What is a value?
The stuff programs remember — and every value has a type.
- 1.2What REALLY happens when you create a variable
A slot, a value, and a name tied on like a label.
- 1.3Reassignment
The label stays; the contents get swapped.
- 1.4let vs const vs var
Welded labels, and one old leaky keyword.
- 1.5Numbers
Arithmetic — and the honest truth about 0.1 + 0.2.
- 1.6Strings
Text as a train of indexed characters.
- 1.7Booleans, null & undefined
"Never set" vs "deliberately empty".
- 1.8typeof & dynamic typing
Values have types. Variables just point.
- 1.9Type coercion & comparison
The machine that silently converts — and why === is home.
- 1.10Operators roundup
Expressions as trees; values bubbling up.
- 1.11Checkpoint: the Mad Libs machine
Build a story generator with everything so far.