A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-32.js
1functionf(){
2try{console.log(y);lety=1;}
3catch(e){console.log(e.constructor.name);}
4}
5f();
Scope
Answer & explanation
Console output
ReferenceError
Why
A let binding is hoisted to the top of its block, but it lives in the Temporal Dead Zone (TDZ) from the start of the block until the declaration is evaluated. Accessing it inside the TDZ throws a ReferenceError, not undefined like var would. This is why let catches use-before-declaration mistakes that var silently hides.