The Memory Allocation Phase, where memory is reserved and hoisting happens, and the Code Execution Phase, where the code runs line-by-line.
What Is an Execution Context in JavaScript?
What are the two phases of execution context?
The answer
More FAQs in What Is an Execution Context in JavaScript?
It is the environment where JS code is evaluated and executed. It has two phases: memory allocation (variables get undefined, functions are stored) and code execution (values are assigned, functions run).
A global execution context is created once when the program starts. A function execution context is created every time a function is invoked, pushed onto the call stack, and destroyed when the function returns.
Hoisting happens in the memory allocation phase. Variables declared with var get undefined, function declarations are stored in full. This makes them usable before their line of declaration.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.