Logo
HTMLCSSJavaScriptReactjsnewContactUpdates

Get started today

HTMLCSSJavaScriptReactjsnewContactUpdates

Tools

Resume BuilderQR GeneratorVS Code Editor

Connect

GitHubWhatsApp Channel
scope
var let const

Javascript Global Execution Context

By Saket Bhatnagar•June 14, 2025•Beginner to Intermediate

Table of Contents

  1. global execution context
  2. window variable
  3. JavaScript code run in two phases
  4. Variable Phase
  5. Execution Phase

global execution context

  1. 1When we give JS code to the browser, JS Engine will allocate (create) a global memory block for the execution of JavaScript code, called Global Execution Context.
  2. 2 Here, we have a window variable which have reference of Global Execution Context.

window variable

  1. 1Window variable or window object -> everything is object in js.
  2. 2Window is a global variable which store the reference of Global Execution Context
  3. 3Window object is also known as Global Object because it is available anywhere in the program.
  4. 4Window object have pre-defined state and behaviour.
  5. 5 Variable declared with var always goes to global scope and can be accessible by window object.
  6. 6 Any variable created in global scope will be addes in Window object implicitly by JS Engine.

JavaScript code run in two phases

  1. 1Variable phase
  2. 2Execution phase

Variable Phase

  1. 1In variable phase, JS Engine will check the complete JS Code and it will search for variable declaration statement.
  2. 2 If variable is declared then JS Engine allocate (provide) memory for them.
  3. 3Variable declared with var will be initialized storing "undefined" at the time of memory block creation.
    Variable declared with let and const will remain uninitialized (empty) at the time of memory block creation.

Execution Phase

  1. 1In Execution phase, JS Engine will execute the instruction line-by-line.

Share this article

Last updated: July 14, 2025

Join Our Community

Login to Join

© 2025 Saket Bhatnagar. All rights reserved.

    ☕