Skip to content
Learn Netverks

Lesson

Step 6/36 17% through track

variables-let-const

let, const, and var

Last reviewed May 28, 2026 Content v20260528
Track mode
client_javascript
Means
In-browser JS
Reading
~1 min
Level
beginner

This lesson

This lesson teaches let, const, and var—the ideas, syntax, and habits you need before moving on in JavaScript.

Reusable tokens and variables keep large stylebases consistent and cheaper to retheme.

You will apply let, const, and var in contexts like: Browsers, Node.js services, edge workers, and tooling ecosystems (bundlers, test runners).

Run JavaScript in the in-browser sandbox, use the terminal output panel, and verify with MCQs.

When the previous lesson's MCQs feel easy and you can explain let, const, and var in your own words.

Bindings store values. Prefer const by default, let when reassignment is required, and avoid var in modern code (function scope quirks).

Rules of thumb

  • const — cannot reassign the binding (object contents may still mutate)
  • let — block-scoped reassignment
  • var — legacy; hoisted function scope—avoid in new code

Block scope

let/const exist only inside { } blocks—prevents loop variable leaks.

Important interview questions and answers

  1. Q: const vs immutable object?
    A: const blocks rebinding, not deep freeze of object properties.
  2. Q: Why avoid var?
    A: Hoisting and function scope cause subtle bugs in loops and conditionals.

Self-check

  1. When use let instead of const?
  2. What is temporal dead zone?

Tip: Default to const; use let only when reassigning.

Interview prep

Prefer const?

Signals immutability of binding; reduces accidental reassignment.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What would you log to verify this behavior?
  • What breaks if you run this before the DOM is ready?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump