Skip to content
2 min read
Mastering JavaScript

Value, reference, and scope in JavaScript

Before advanced patterns make sense, you need three fundamentals: values, references, and scope.

Values vs references

Primitives (numbers, strings, booleans, etc.) are copied by value. Objects and arrays are referenced — assigning or passing them shares the same underlying data unless you intentionally copy.

That distinction explains a lot of “why did this mutate?” bugs.

Scope

Scope answers where a variable is visible. Nested functions can read outer scopes; outer code cannot reach into an inner block. Modern JS also has block scope via let and const.

Get comfortable drawing a quick mental diagram of scopes when reading unfamiliar code. It makes closures, hoisting, and module boundaries much easier later.

This was the kickoff of my Master JS notes — more concepts followed in the series.

Open on Instagram