Fundamentals / Variables
var, let & const
A variable is a labeled box. Reassignment changes what's inside the box, not the label.
A variable is a name bound to a memory slot. `var` and `let` create slots you can write to again later. `const` creates a slot that must be given a value once and never reassigned — though if that value is an object, the object's contents can still change.
Declaration and initialization are two separate moments: `let count;` creates the slot (declaration), `count = 10` fills it (initialization). You can combine both in one line.
Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
Memory
Declare a variable to see it in memory
Why?
`count` is a name that points at one memory slot. Assignment overwrites the slot's contents — the name never moves, only the value underneath it does.