What happens to let and const in the memory allocation phase?
Memory is allocated, but they remain uninitialized in the Temporal Dead Zone. Accessing them before the declaration line throws a ReferenceError.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in JavaScript Memory Allocation Phase Explained
The first phase of execution context creation. The engine scans the code, allocates memory for variables and functions, assigns undefined to var variables, places let/const in the TDZ, and stores function declarations in full.
Function declarations are fully stored during memory allocation. Function expressions are treated as variables assigned undefined (with var), so calling them before assignment throws a TypeError.
undefined. The declaration is hoisted but the assignment is not. Only when the code execution phase reaches the assignment line does the variable get its real value.
Still have questions?
Browse all our FAQs or reach out to our support team
