Phase 4 · JavaScript
TopicsVariables
Part of the Frontend Developer Roadmap.
Summary
`var`, `let` and `const` declare storage for values — each with different scoping and reassignment rules that trip up nearly every JS beginner. In modern JavaScript, `const` and `let` are usually preferred because block scoping makes variable lifetime easier to reason about and reduces accidental reassignment.
How to Learn This
- 1Compare `var` vs `let` scoping by logging a variable inside and outside a block. Write down when you would choose each option and what trade-off drives that choice.
- 2Default to `const`, use `let` only when reassignment is needed, avoid `var`. Know the exception cases as well, so you can make the choice deliberately.
- 3Learn the 'temporal dead zone' that `let`/`const` introduce.
More topics in JavaScript
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — free on the InsideEdge app.