Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Variables – var, let & const | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 2 of 55

·javascript

Variables – var, let & const

9 mins

Course progress4%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `let` and `const` are block‑scoped and prevent many bugs caused by `var`.
  • `const` does **not** make the value immutable – objects can still be mutated.
  • Variables declared with `var` are hoisted to the top of their function.

Three ways to declare variables:

KeywordScopeRe‑assignmentHoisting
varFunction‑scoped✅Yes (initialised as undefined)
letBlock‑scoped✅No (Temporal Dead Zone)
constBlock‑scoped❌ (immutable binding)No (TDZ)

Example:

var a = 1;      // function‑scoped, can be redeclared
let b = 2;      // block‑scoped, cannot be redeclared in the same block
const C = 3;    // block‑scoped, constant binding
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonWhat is JavaScript?Continue to lesson 3Data Types & Type‑CoercionBack to JavaScript Course curriculum