<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rudresh Shukla</title>
    <description>The latest articles on DEV Community by Rudresh Shukla (@rudreshshukla592).</description>
    <link>https://dev.to/rudreshshukla592</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4038433%2Fc9360414-02a5-4c1d-b5bf-a973ff33bc62.jpg</url>
      <title>DEV Community: Rudresh Shukla</title>
      <link>https://dev.to/rudreshshukla592</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rudreshshukla592"/>
    <language>en</language>
    <item>
      <title>JavaScript Under the Hood #1: From Source Code to the Call Stack</title>
      <dc:creator>Rudresh Shukla</dc:creator>
      <pubDate>Mon, 20 Jul 2026 15:43:53 +0000</pubDate>
      <link>https://dev.to/rudreshshukla592/javascript-under-the-hood-1-from-source-code-to-the-call-stack-4n3i</link>
      <guid>https://dev.to/rudreshshukla592/javascript-under-the-hood-1-from-source-code-to-the-call-stack-4n3i</guid>
      <description>&lt;p&gt;Every time you run a JavaScript program, a lot happens behind the scenes. Variables are allocated memory, execution contexts are created, functions are pushed onto the call stack, and the engine starts executing your code. But before we dive into all of that, let's first understand what JavaScript actually is and why it was created.&lt;/p&gt;

&lt;h2&gt;
  
  
  An Introduction to JavaScript
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is JavaScript?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript is a programming language that was originally created in 1995 by Brendan Eich in just 10 days while he was working at Netscape.&lt;/li&gt;
&lt;li&gt;JavaScript is a high-level programming language primarily used to make web pages interactive. Today, it is also used to build servers, mobile applications, desktop software, and much more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why was JavaScript created?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript was created to make web pages &lt;strong&gt;alive&lt;/strong&gt;. But what does "alive" mean? it means adding interactivity (e.g.,  animations, clickable buttons, popup menus, etc.) to the static web pages.&lt;/li&gt;
&lt;li&gt;Today, JavaScript isn't limited to browsers. With runtimes like Node.js, it can also be used to build backend applications and APIs, which allow you to add more functionality to a website.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Did you know? When JavaScript was created, it initially had another name: “LiveScript”. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Where can JavaScript be used?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In your browser — every interactive website uses it (Facebook, YouTube, Gmail).&lt;/li&gt;
&lt;li&gt;On servers — through Node.js, you can build backend APIs.&lt;/li&gt;
&lt;li&gt;In mobile apps — using frameworks like React Native.&lt;/li&gt;
&lt;li&gt;In desktop apps — VS Code itself is built using JavaScript (Electron).&lt;/li&gt;
&lt;li&gt;In smart devices, games, robots, and much more.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we know what JavaScript is, another question comes to mind: &lt;strong&gt;How does JavaScript execute my code?&lt;/strong&gt; Before answering that, let's first understand &lt;strong&gt;Who executes my code?&lt;/strong&gt;.&lt;br&gt;
The answer is: &lt;strong&gt;The JavaScript Engine&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The JavaScript Engine
&lt;/h2&gt;

&lt;p&gt;We already know what &lt;strong&gt;JavaScript&lt;/strong&gt; is, but what exactly is this &lt;strong&gt;engine&lt;/strong&gt;?&lt;/p&gt;
&lt;h3&gt;
  
  
  The "Engine"
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A JavaScript engine is a piece of software responsible for executing JavaScript code. Every environment that runs JavaScript, whether it's a browser or Node.js, has its own JavaScript engine. &lt;/li&gt;
&lt;li&gt;But this raises another question: &lt;strong&gt;Why do we even need an engine?&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Why Do We Need a JavaScript Engine?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript cannot execute code on its own. It needs an engine that understands JavaScript syntax and converts it into instructions the computer can execute. Every environment that runs JavaScript has its own engine. For example, Chrome and Node.js use V8, Firefox uses SpiderMonkey, and Safari uses JavaScriptCore.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  How Does the Engine Execute Code?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Modern JavaScript engines process your code in three simple steps:&lt;/li&gt;
&lt;li&gt;Parsing&lt;/li&gt;
&lt;li&gt;Interpreting&lt;/li&gt;
&lt;li&gt;Compiling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, these steps are part of a technique known as &lt;strong&gt;Just-In-Time (JIT)&lt;/strong&gt; compilation, which helps JavaScript run quickly while remaining efficient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────┐
│  JavaScript Source Code │
└────────────┬────────────┘
             │
             ▼
┌─────────────────────────┐
│   JavaScript Engine     │
└────────────┬────────────┘
             │
             ▼
┌─────────────────────────┐
│   Parses the Code       │
└────────────┬────────────┘
             │
             ▼
┌─────────────────────────┐
│ Processes &amp;amp; Executes It │
└────────────┬────────────┘
             │
             ▼
┌─────────────────────────┐
│ Creates an Execution    │
│ Context                 │
└─────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we know who executes our code and how the engine processes it, let's look at what actually happens the moment JavaScript starts running our program. This is where the concept of an &lt;strong&gt;Execution Context&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Execution Context
&lt;/h2&gt;

&lt;p&gt;Whenever JavaScript executes a program, it always runs inside an execution context.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an Execution Context (EC)?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;An Execution Context is the &lt;strong&gt;environment&lt;/strong&gt; in which a piece of JavaScript code is evaluated and executed. &lt;/li&gt;
&lt;li&gt;Think of it as a sealed container that holds everything the code needs to run: its variables, functions, and the value of &lt;code&gt;this&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────┐
│   JavaScript Code    │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Execution Context    │
├──────────────────────┤
│ • Variables          │
│ • Functions          │
│ • Memory             │
│ • this               │
└──────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why Do We Need an Execution Context (EC)?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Let's look at an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We know that our code does not run as-is. The JavaScript Engine parses the code and then creates an execution context. The Execution context(EC) is necessary because it allocates memory for variables and functions before the code starts executing.&lt;/li&gt;
&lt;li&gt;So, in this example, the code isn't executed immediately. Before JavaScript starts running each line, the execution context first allocates memory for variables and functions.&lt;/li&gt;
&lt;li&gt;But how does JavaScript allocate memory before executing the code? Let's understand that by looking at the two phases of an execution context.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But before that comes the &lt;strong&gt;types&lt;/strong&gt; of Execution Context.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Execution Context
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Global Execution Context (GEC)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whenever a JavaScript program starts executing, a Global Execution Context (GEC) is created.&lt;/li&gt;
&lt;li&gt;A JavaScript program has only &lt;strong&gt;one&lt;/strong&gt; Global Execution Context (GEC).&lt;/li&gt;
&lt;li&gt;It is also known as the &lt;strong&gt;Base Execution Context&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Function Execution Context (FEC)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When we invoke (call) a function, a Function Execution Context gets created.&lt;/li&gt;
&lt;li&gt;Each function call gets its own private context with its own variables.&lt;/li&gt;
&lt;li&gt;When the function finishes, its FEC is destroyed. &lt;/li&gt;
&lt;li&gt;A Function Execution Context is created during the &lt;strong&gt;Code Execution Phase&lt;/strong&gt; whenever a function is called.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Phases of an Execution Context
&lt;/h3&gt;

&lt;p&gt;This is one of the most important concepts in the whole topic. Every EC is built in two phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Phase 1 — Memory Creation Phase&lt;/strong&gt;&lt;br&gt;
Before any line runs, JS scans the code and sets up memory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If there are any &lt;strong&gt;variables&lt;/strong&gt; declared in the code, memory is allocated for the variable. The variables are set to &lt;code&gt;undefined&lt;/code&gt; in this phase.&lt;/li&gt;
&lt;li&gt;If there is a &lt;code&gt;function&lt;/code&gt; declaration in the code, the entire function is stored in memory as-is. &lt;/li&gt;
&lt;li&gt;Also, in this phase, two special values become available:

&lt;ol&gt;
&lt;li&gt;The global object (&lt;code&gt;window&lt;/code&gt; in browsers).&lt;/li&gt;
&lt;li&gt;The global &lt;code&gt;this&lt;/code&gt; value. &lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Phase 2 — Code Execution Phase&lt;/strong&gt;&lt;br&gt;
The code execution starts in this phase.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Here, the real values are assigned to the global variables which were initially set &lt;code&gt;undefined&lt;/code&gt; in Phase 1.&lt;/li&gt;
&lt;li&gt;If there is a function call in the code, then it creates a Function Execution Context in this phase.&lt;/li&gt;
&lt;li&gt;JavaScript waits until that function finishes executing before continuing with the remaining code.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vivek&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now here's what happens:

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Memory Creation Phase&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;username&lt;/code&gt; =&amp;gt; &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;greet&lt;/code&gt; =&amp;gt; full function stored.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;this&lt;/code&gt; =&amp;gt; set to &lt;code&gt;window&lt;/code&gt; object.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code Execution Phase&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;username&lt;/code&gt; becomes &lt;strong&gt;Vivek&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Then &lt;code&gt;greet()&lt;/code&gt; is called → a new Function Execution Context is created

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Memory Creation Phase&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;message&lt;/code&gt; → &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Execution Phase&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;message&lt;/code&gt; becomes &lt;strong&gt;Hello&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hello&lt;/strong&gt; gets printed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;The FEC gets destroyed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vivek&lt;/strong&gt; gets printed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Final Output: 

&lt;ul&gt;
&lt;li&gt;Hello&lt;/li&gt;
&lt;li&gt;Vivek
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────────────────┐
│ Global Execution Context (GEC)   │
├──────────────────────────────────┤
│ • Memory Creation Phase          │
│ • Code Execution Phase           │
└───────────────┬──────────────────┘
                │
                │ greet()
                ▼
┌──────────────────────────────────┐
│ Function Execution Context (FEC) │
├──────────────────────────────────┤
│ • Memory Creation Phase          │
│ • Code Execution Phase           │
└───────────────┬──────────────────┘
                │
                │ Function ends
                ▼
        Return to the GEC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Since memory is created before code executes, this leads us to one of JavaScript's most misunderstood concepts: Hoisting.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hoisting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Hoisting?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Hoisting is JS's behaviour of &lt;strong&gt;appearing&lt;/strong&gt; to move declarations of functions and variables to the top of their &lt;strong&gt;scope&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;Important: nothing physically moves — this is just the &lt;strong&gt;Creation Phase&lt;/strong&gt; allocating memory before the code runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why Does Hoisting Happen?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the Execution Context, memory is created before code executes. This leads to Hoisting.&lt;/li&gt;
&lt;li&gt;Let's take an example.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vivek&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The output of above code is &lt;code&gt;undefined&lt;/code&gt;. But why? Suppose we use similar code in some other programming language. In that case, we may get an error saying the variable name is not declared, as we are trying to access it well before that.&lt;/li&gt;
&lt;li&gt;Let's visualize the &lt;strong&gt;Global Execution Context&lt;/strong&gt; for the example which will give us more clarity:

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Memory Creation Phase&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; =&amp;gt; &lt;code&gt;undefined&lt;/code&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code Execution Phase&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;console.log(name)&lt;/code&gt; =&amp;gt; prints &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt; =&amp;gt; &lt;strong&gt;Vivek&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;See what happened here in the &lt;strong&gt;Code Execution Phase&lt;/strong&gt; the console.log() prints the value of &lt;code&gt;name&lt;/code&gt; before it can even be assigned to its real value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Hoisting with var
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; declarations are hoisted and set to &lt;code&gt;undefined&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;So you can access them before the line they're written on — you just get &lt;code&gt;undefined&lt;/code&gt;, not an error.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined  (not an error!)&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Hoisting with let &amp;amp; const
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are hoisted too — but they are not initialized.&lt;/li&gt;
&lt;li&gt;From the start of their scope until the line where they are declared, they sit in the &lt;strong&gt;Temporal Dead Zone (TDZ)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;So, accessing them before their declaration throws a &lt;code&gt;ReferenceError&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ ReferenceError: Cannot access 'a' before initialization&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// OR&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ ReferenceError: Cannot access 'b' before initialization&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Temporal Dead Zone (TDZ)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is a specific region of a block scope where a variable exists but is completely inaccessible before its actual declaration line.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Attempting to access, read, or write to a variable while it is trapped in the TDZ will immediately throw a &lt;code&gt;ReferenceError&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For this example, the &lt;strong&gt;Global Execution Context (GEC)&lt;/strong&gt; is visualized below, showing the &lt;strong&gt;Temporal Dead Zone (TDZ)&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ ReferenceError: Cannot access 'b' before initialization&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────────────────────────────┐
│                   Global Execution Context (GEC)                   │
├────────────────────────────────────────────────────────────────────┤
│                                                                    |
│   Memory Creation Phase                                            │
│   ────────────────────────────────────────                         │
│   b  →  &amp;lt;uninitialized&amp;gt;   ← NOT undefined                          │
│                                                                    │
├────────────────────────────────────────────────────────────────────┤
│                                                                    │
│   Code Execution Phase                                             │
│   ────────────────────────────────────────                         │
│   console.log(b);                                                  │
│   ▲                                                                │
│   │                                                                │
│   │   [ERROR] Temporal Dead Zone (TDZ)                             │
│   │   Cannot access 'b' before initialization                      │
│   │                                                                │
│   let b = 10;   ← TDZ ends here                                    │
│                                                                    │
│   b = 10                                                           │
│                                                                    │
└────────────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Remember&lt;/p&gt;

&lt;p&gt;Hoisting is not JavaScript moving your code.&lt;br&gt;
It's the result of the Memory Creation Phase, where memory is allocated before the Code Execution Phase begins.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Call Stack
&lt;/h2&gt;

&lt;p&gt;JavaScript can execute only one piece of code at a time. So whenever a function is called, JavaScript needs a way to remember where it currently is and which function should execute next. This is exactly what the &lt;strong&gt;Call Stack&lt;/strong&gt; does.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Call Stack?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Call Stack is a data structure that tracks the execution of functions and keeps track of which function is currently running.&lt;/li&gt;
&lt;li&gt;It is a mechanism used by the JavaScript engine.&lt;/li&gt;
&lt;li&gt;It works on LIFO — Last In, First Out principle.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why Do We Need a Call Stack?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Without the call stack, JavaScript would quickly break down for the following critical reasons:&lt;/li&gt;
&lt;li&gt;Tracking where JavaScript currently is.&lt;/li&gt;
&lt;li&gt;Executing functions in the correct order.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How Does the Call Stack Work?
&lt;/h3&gt;

&lt;p&gt;The Call Stack operates on a Last-In, First-Out (LIFO) principle. Think of it like a stack of books—the last book you put on top is the first one you must take off.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Push&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you call (invoke) a function =&amp;gt; it gets added (pushed) to the top of the stack.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Pop&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When a function returns / finishes =&amp;gt; JavaScript removes (pops) it off the top of the stack.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Call Stack Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;one&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;One&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;two&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;one&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Two&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;three&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;two&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Three&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;three&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step-by-step stack movement:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Stack (top → bottom)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;three()&lt;/code&gt; called&lt;/td&gt;
&lt;td&gt;three → GEC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;two()&lt;/code&gt; called inside three&lt;/td&gt;
&lt;td&gt;two → three → GEC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;one()&lt;/code&gt; called inside two&lt;/td&gt;
&lt;td&gt;one → two → three → GEC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;one()&lt;/code&gt; finishes → prints&lt;/td&gt;
&lt;td&gt;(pops one) two → three → GEC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;two()&lt;/code&gt; finishes → prints&lt;/td&gt;
&lt;td&gt;(pops two) three → GEC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;three()&lt;/code&gt; finishes → prints&lt;/td&gt;
&lt;td&gt;(pops three) GEC&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Visualization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Initial Call Stack&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. &lt;code&gt;three()&lt;/code&gt; called&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│    three()   │
├──────────────┤
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;two()&lt;/code&gt; called&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│    two()     │
├──────────────┤
│    three()   │
├──────────────┤
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. &lt;code&gt;one()&lt;/code&gt; called&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│    one()     │
├──────────────┤
│    two()     │
├──────────────┤
│    three()   │
├──────────────┤
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. &lt;code&gt;one()&lt;/code&gt; finishes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│    two()     │
├──────────────┤
│    three()   │
├──────────────┤
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. &lt;code&gt;two()&lt;/code&gt; finishes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│    three()   │
├──────────────┤
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. &lt;code&gt;three()&lt;/code&gt; finishes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Output order:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;One&lt;/li&gt;
&lt;li&gt;Two&lt;/li&gt;
&lt;li&gt;Three&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Stack Overflow
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Since memory is finite, the Call Stack has a size limit.&lt;/li&gt;
&lt;li&gt;If functions keep getting pushed without ever popping (usually infinite recursion), the stack runs out of space and the engine throws:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// calls itself forever, never returns&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// ❌ RangeError: Maximum call stack size exceeded&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Every recursive function must have a base case that stops the recursion, otherwise → stack overflow.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Remember&lt;/p&gt;

&lt;p&gt;The Call Stack doesn't run your code — it just tracks &lt;em&gt;where&lt;/em&gt; the engine currently is. LIFO in, LIFO out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Putting It All Together
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Now rather than introducing any new concept Let's solve an example for better clarity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Vivek&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Execution Flow&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JavaScript Source Code
          │
          ▼
┌──────────────────────┐
│ JavaScript Engine    │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Global Execution     │
│ Context Created      │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Memory Creation      │
│ Phase                │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Code Execution       │
│ Phase                │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Function Call        │
│ greet()              │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Function Execution   │
│ Context              │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│ Console Output       │
│ Hello                │
│ Vivek                │
└──────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Global Execution Context&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────┐
│ Global Execution Context                   │
├────────────────────────────────────────────┤
│ Memory Creation Phase                      │
├────────────────────────────────────────────┤
│ username → undefined                       │
│ greet    → Entire Function Stored          │
│ this     → window                          │
├────────────────────────────────────────────┤
│ Code Execution Phase                       │
├────────────────────────────────────────────┤
│ username = "Vivek"                         │
│ greet() ← Function Called                  │
│ console.log(username)                      │
└────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Call Stack&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Initial Call Stack&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. &lt;code&gt;greet()&lt;/code&gt; called&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│   greet()    │
├──────────────┤
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;greet()&lt;/code&gt; finishes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐
│     GEC      │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Final Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Console

Hello
Vivek
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Summary (End the article with this)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In this article, we followed the complete journey of a JavaScript program—from understanding what JavaScript is, to learning how the JavaScript Engine processes code, how an Execution Context is created, why Hoisting occurs, and finally how the Call Stack manages function execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;These concepts form the foundation of JavaScript. Once they become clear, understanding advanced topics like Closures, the Event Loop, Promises, and Async/Await becomes much easier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the next part of this series, we'll dive deeper into how JavaScript handles asynchronous operations and explore the Event Loop in detail.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;If you found this article helpful, consider leaving a ❤️ and sharing your thoughts in the comments.&lt;/p&gt;

&lt;p&gt;The next article in this series will cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript Event Loop&lt;/li&gt;
&lt;li&gt;Web APIs&lt;/li&gt;
&lt;li&gt;Callback Queue&lt;/li&gt;
&lt;li&gt;Microtasks vs Macrotasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you in Part 2!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
