beginner · 22 minute study
Names, values and shared objects
Before learning many keywords, learn to track what a name refers to and which changes are visible elsewhere. This prevents confusion in every later language and UI state lesson.
First, build a mental model
A variable is a named binding to a value. An object reference is itself a value that can be copied: two bindings can then reach the same mutable object. Rebinding a name and mutating an object are different operations.
- Values represent information: numbers, text, decisions, collections and structured records.
- An assignment changes the value held by one binding. It does not search for every other binding that previously held an equal value.
- Copying a reference can share an object; changing one of that object's fields is observable through other references.
- Types describe the operations a value supports. A static checker and a runtime value check act at different times.
- The JavaScript example makes the idea concrete. Use the comparison lab to notice where C# structs or another language's rules differ.
let first = 3;
let second = first;
second = 5;
const basket = { count: 3 };
const shared = basket;
shared.count = 5;
console.log(first);
console.log(basket.count);- Copy a number
second receives 3. Reassigning second to 5 leaves first at 3.
- Copy a reference
shared and basket reach the same object.
- Mutate the object
That object's count becomes 5, so basket.count is also 5.
Production thinking
Take this beyond the example.
Draw ownership before changing shared state. One accidental alias can affect UI previews, cached API results or game saves even when all fields have valid types.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · Turn a rule into a small, testable contract →