Does var have a Temporal Dead Zone?
No. var is initialized to undefined during the memory allocation phase, so accessing it early returns undefined instead of throwing. Only let and const have a TDZ.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Temporal Dead Zone (TDZ) in JavaScript Explained
The period between entering a scope where a let or const variable is declared and reaching the declaration line. Accessing the variable during this period throws a ReferenceError.
ReferenceError: Cannot access 'x' before initialization. It is thrown when you try to read or use a let or const variable before its declaration line.
Yes. Default parameters are evaluated left to right. A parameter that references a later parameter throws ReferenceError because that later parameter is still in the TDZ.
Still have questions?
Browse all our FAQs or reach out to our support team
