Back to articles
Execution Context in JavaScript

Execution Context in JavaScript

via Dev.to BeginnersKhafido Ilzam

Execution context is one of the most fundamental concepts in JavaScript — it's the environment in which JavaScript code is evaluated and executed. What Is an Execution Context? Every time JavaScript runs code, it creates an execution context — a wrapper that holds information about the current code being run: what variables are available, what this refers to, and the outer environment it has access to. There are three types: Global Execution Context (GEC) — created once when the script first runs Function Execution Context (FEC) — created every time a function is invoked Eval Execution Context — created inside eval() calls (rarely used, mostly avoided) Every execution context goes through two distinct phases: Phase 1: Creation Phase (Memory / Hoisting Phase) Before any code runs, the JavaScript engine scans the code and: Creates the Variable Environment (stores var declarations, initialized to undefined) Creates the Lexical Environment (stores let/const declarations in the Temporal Dea

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
3 views

Related Articles