Logo
HTMLCSSJavaScriptReactjsnewResourcesContactUpdates
Join

Get started today

HTMLCSSJavaScriptReactjsnewResourcesContactUpdates

Tools

Resume BuilderQR GeneratorVS Code Editor

Connect

GitHubWhatsApp Channel
hoisting and temporal dead zone
function

Var Let Const

By Saket Bhatnagar•February 22, 2026•Beginner to Intermediate

Table of Contents

  1. Var
  2. Let
  3. Const
  4. Practice Questions

Var

  1. 1Variable declared with var goes to global scope.
  2. 2We can redeclare variable with same name in same scope.
  3. 3We can update the value of variable.
  4. 4We can declare variable without initialization.
  5. 5Variable declared with var , can be hoisted.
  6. 6Variable declared inside block , will go to global scope.
  7. 7Variable declared inside function , will not go to global scope. It will be accessible inside function only.

Let

  1. 1Variable declared with let is block scoped.
  2. 2We cannot redeclare variable with same name in same scope.
  3. 3We can update the value of variable.
  4. 4We can declare variable using let without initialization. But js engine will keep that memory block uninitialized (empty) untill js engine reads declaration statement in execution phase.
  5. 5Because let variable is uninitialized (empty) in variable phase , it belongs to Temporal Dead Zone.
  6. 6The variable declared using let does not belongs to global scope , we cannot access them with the help of window variable.
  7. 7The variable declared using let is hoisted and belongs to temporal deadzone. Therefore it cannot be used before initialization (because at that moment it is uninitialized - TDZ) .
  8. 8Variable declared inside function will be accessible inside function only.

Const

  1. 1Variable declared with const is block scope.
  2. 2We cannot redeclare variable with same name in same scope.
  3. 3The value of variable can not be modified.
  4. 4We can not declare const without initialization.
  5. 5The variable declared using const is hoisted and belongs to temporal deadzone. Therefore it cannot be used before initialization (because at that moment it is uninitialized - TDZ) .
  6. 6The variable declared using const inside block ,does not belongs to global scope we cannot use them with the help of window.
  7. 7Variable declared inside function will be accessible inside function only.

Practice Questions

  1. 1
    1console.log("start");
    2let a = 10;
    3var b = 20;
    4const c = 30;
    5{
    6 let a = 100;
    7 var b = 200;
    8 const c = 300;
    9 console.log(a);
    10 console.log(b);
    11 console.log(c);
    12}
    13console.log(a);
    14console.log(b);
    15console.log(c);
    16console.log("end");
  2. 2
    1console.log("start");
    2let a = 10;
    3console.log(b);
    4{
    5 var b = 200;
    6}
    7console.log(a);
    8console.log(b);
    9console.log("end");
  3. 3
    1console.log("start");
    2let a = 10;
    3{
    4 console.log(a);
    5 let a = 10;
    6}
    7console.log(a);
    8console.log(b);
    9console.log("end");
  4. 4
    1console.log("start");
    2var b = 20;
    3const c = 30;
    4{
    5 let a = 100;
    6 console.log(a);
    7 console.log(b);
    8 console.log(c);
    9}
    10console.log(a);
    11console.log(b);
    12console.log("end");
  5. 5
    1console.log("start");
    2let a = 10;
    3var b = 20;
    4const c = 30;
    5{
    6 let a = 10;
    7 console.log(a);
    8 const c = 300;
    9 console.log(b);
    10 b = 200;
    11 c = 30;
    12 console.log(b);
    13}
    14console.log(a);
    15console.log(b);
    16console.log("end");

Share this article

Last updated: March 22, 2026

Saket Bhatnagar

I build products, share the playbooks, and pass along everything I learn so you can ship faster.

GitHubLinkedInYouTubeWhatsApp Channel

Quick Links

  • Updates
  • Resources
  • Resume Builder
  • Contact

WhatsApp

Builders Group

Real-time notes from my builds, weekend challenges, and accountability threads.

Shipping Notes Channel

Launch alerts + bite-sized lessons.

© 2026 Saket Bhatnagar. All rights reserved.

Always building, always learning.