JS Sketchbooksee JavaScript think ✏️
← back to the map
1

Values & Variables

foundation — everything stands on this

The big question: “What happens in memory when I create a variable?”

but why do we need this?

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.

in plain words

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.

words you’ll own after this
value

One piece of data: 25, "hello", or true.

variable

A named memory box holding one value, so the program can use it later by name.

declare

Creating the variable — “machine, reserve a box and call it age.”

assign

Putting a value into the box. The = sign means “put this in”, NOT “equals”.

type

What kind of value something is: number, text (string), true/false (boolean)… The kind decides what you can do with it.

undefined vs null

undefined = “nobody ever put anything in this box.” null = “someone deliberately put nothing in it.”

after this phase, you can…
  • 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
this phase’s lab — see it move

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.

memory
the lessons
  1. 1.1
    What is a value?

    The stuff programs remember — and every value has a type.

  2. 1.2
    What REALLY happens when you create a variable

    A slot, a value, and a name tied on like a label.

  3. 1.3
    Reassignment

    The label stays; the contents get swapped.

  4. 1.4
    let vs const vs var

    Welded labels, and one old leaky keyword.

  5. 1.5
    Numbers

    Arithmetic — and the honest truth about 0.1 + 0.2.

  6. 1.6
    Strings

    Text as a train of indexed characters.

  7. 1.7
    Booleans, null & undefined

    "Never set" vs "deliberately empty".

  8. 1.8
    typeof & dynamic typing

    Values have types. Variables just point.

  9. 1.9
    Type coercion & comparison

    The machine that silently converts — and why === is home.

  10. 1.10
    Operators roundup

    Expressions as trees; values bubbling up.

  11. 1.11
    Checkpoint: the Mad Libs machine

    Build a story generator with everything so far.