Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

JavaScript Execution Context and Call Stack Explained

Why Execution Context is important in JavaScript ? When I first learnt JavaScript, I tried to memorize syntax but struggled to understand why the code behaved the way it did. What are all these jargons like : Hoisting, Scope, Closure,…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




Why Execution Context is important in JavaScript ?



When I first learnt JavaScript, I tried to memorize syntax but struggled to understand why the code behaved the way it did.



What are all these jargons like : Hoisting, Scope, Closure, async behavior ?



All became easy once I understood Execution Context & Call stack.



So, this is where my JavaScript learning journey begins, and from today onwards, I will be sharing my learning so that it can be easy for you all to learn these concepts.



Let’s start with the very first question.






What is Execution Context?



An Execution context is the environment where JavaScript code is evaluated and executed.



What does it mean by this line? Let me explain.



Think of it as a big container created by JS to run your code. Everything in JS runs inside an execution context. Every time JS runs code, it creates an execution context.






What is inside an execution context?



The execution context is created in two phases.




  1. Memory Creation Phase

  2. Code Execution Phase



Phase 1 - Memory Creation Phase :



Before executing the code, JS stores variables and functions in the memory.



During this phase :




  • In the memory component everything is stored in key-value pairs.

  • Variables are stored with a special keyword “undefined“ (I will talk about it in another blog).

  • Functions are stored as it is.



Phase 2 - Code Execution Phase :



In this phase :




  • Code will be executed one line at a time.

  • Variable values are updated with the values written in the code.

  • Functions are invoked/executed in this phase.

  • Function calls are pushed onto the Call Stack.



This is also known as Thread of Execution. This is why JavaScript is called Synchronous Single Threaded language.



What does it mean by Synchronous Single Threaded ?



It means the code will execute one line at a time in a particular order that is, after finishing the execution of one line, the next line will executes.






Types of Execution Context




  1. Global Execution Context :




  • It is created when JS file first runs.

  • Only one global context exists.




  1. Function Execution Context :




  • It is created every time a function is called.

  • Can be as many as functions are invoked in the code.

  • When a function is created, a new execution context is created.






Example to Visualize Execution Context



Let’s understand the flow of execution context with an example





In the memory creation phase, variable n will be stored with undefined. and function will be stored as it is and everything is stored in key-value pairs. We can see this in developer console.





In code execution phase a global execution is created and variables will assigned with its value written in the code. The code will execute one line by line at a time in a particular order.







So, n is assigned with value 5.



Now when the 6th line is executed, the multiplyByTwo() function is invoked with an argument n and a new execution context is created and pushed into the Call Stack.





This is known as Function Execution Context. Once the code execution is completed and the value is assigned into output1, the execution context is popped from the call stack.



Similarly for output2, the same process happens.






What Is the Call Stack?



The Call Stack is a data structure that keeps track of execution contexts. It follows LIFO - Last In, First Out principle.



JavaScript has it own call stack. Call stack maintains the order of the execution of execution context. It is also known as Execution Context Stack / Program Stack / Central Stack / Runtime Stack / Machine Stack.






How Call Stack Works





The order of the call stack is as below :




  1. Global - First, the code executes and global execution context is created.

  2. first() - After this, first() function is invoked and and execution context pushed onto call stack.

  3. second() - Then second function is invoked inside first() and and execution context pushed onto call stack.

  4. third()- Then third function is invoked inside second() and and execution context pushed onto call stack.



Once the third() finishes, it popped from call stack. Then second() and first() finish execution and popped from the call stack as well.






Importance



Understanding execution context helps you:




  • Predict hoisting behavior

  • Debug scope issues

  • Understand closures

  • Avoid call stack overflow

  • Write better async code



Finally, Execution Context & Call Stack are the foundation of JavaScript. Once you understand this:




  • Closures feel logical

  • Async behavior makes sense

  • Debugging becomes easier.



If You like my content and want to connect with me, follow me on LinkedIn(https://www.linkedin.com/in/amohanta).

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - JavaScript Execution Context and Call Stack Explained
id: fd576be6-9eec-4656-a57f-115e9176c255
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-27
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-27"
        description = "YARA Signature for "
    strings:
        $str = "JavaScript Execution Context a" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("JavaScript Execution Context and Call St")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*JavaScript Execution Context and Call St*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "JavaScript Execution Context and Call St"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Analyse für identifizierte Bedrohung auf Basis von Live-CTI (ENISA EUVD): CVSS 0.0 · EPSS 0.0% · CISA KEV: nein. Handlungsableitung aus den verlinkten Hersteller-Quellen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten JavaScript Execution Context and Call Stack Explained

Thematisch verwandte Begriffe: JavaScript, Execution, Context, Call · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-100739 | A vulnerability was detected in mathurvishal CloudClassroom-PHP-Project…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag