What is hoisting and how does it relate to execution context?
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.
Verify This Answer
Cross-check this information using these trusted sources:
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).
The Memory Allocation Phase, where memory is reserved and hoisting happens, and the Code Execution Phase, where the code runs line-by-line.
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.
Still have questions?
Browse all our FAQs or reach out to our support team
