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.
Temporal Dead Zone (TDZ) in JavaScript Explained
Does the TDZ apply to function parameters?
The answer
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.
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.
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.
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.