let f = f;
ReferenceError: can’t access lexical declaration ‘f’ before initialization
I understand that variable declaration proceeds in three steps.
- Declaration
- initialization
- Assignment
So why does the above code produce a reference error?
- Declaration (TDZ)
- let f = f; Reach declaration statement
let f = undefined; //initialization
let f = f; //Why did a reference error occur?
I read the book but there is no answer
New contributor
Soso is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2