1.2 — What REALLY happens when you create a variable
This is the most important lesson of the whole foundation. One tiny line — let age = 25; — and most people learn to read it as “age equals 25” and move on. But you’re here to see what the machine actually does. It does three separate things, in order — and once you can draw them, half of JavaScript’s “weird” behavior stops being weird before you even meet it.
let age = 25; console.log(age);
Read the line as an instruction to the machine: “let there be a thing called age, and put 25 in it.” The keyword let announces: I’m creating a variable. Now watch what physically happens, piece by piece.
The deeper story, with the real names for things — this part is what turns “I saw it” into “I can explain it.”
The proper vocabulary, worth owning: let is a keyword (a word reserved by the language), and age is an identifier (a name you chose).
= is the assignment operator, and the whole line is a declaration with an initial value. When someone says “declare a variable and initialize it to 25,” they mean the three pictures you just watched. Reserve a box, place a value, bind a name.
That word bind is the precise one. The engine keeps a private table that maps names to boxes — “age → box #7,204”. It consults that table every time a name appears.
You never see the table, but knowing it exists explains a lot. A name used before it is created gives a ReferenceError — nothing in the table yet. And two variables can hold the same value without being connected — two boxes, two labels.
One honest disclosure, because this app never lies to you. “A labeled box holding the value” is 90% true — and it is the right picture for numbers, strings and booleans. In Phase 4 you will discover a twist for big things (objects, arrays): their box holds an arrow to the thing, not the thing itself. That twist explains the most common bug family in JavaScript. The label-and-box picture you learned today is the foundation it stands on.
✏️ Quick check 1
In let city = "Chennai";, what is city exactly?
✏️ Quick check 2
Type exactly what the console shows:
let age = 25;
console.log("age");✏️ Quick check 3
You run console.log(salary) but never created salary. Type the NAME of the error that stops the program (one word, ends in Error).
🗣️ Now teach it back
The big one. Explain to a friend what REALLY happens when let age = 25 runs — the three things, in order — and why “age is not the 25” matters.
Write it as if your friend is sitting next to you. Saved to your journal — future-you will use these notes to teach others.