Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

Observing hoisting of let declarations

$
0
0

Can the user observe the hoisting of identifiers declared with let (or const)?

I ask because referring to the identifier before the lexical declaration will always result in a ReferenceError as though it had not been hoisted.

Assume strict mode:

{ a; console.log(a); let a; } // ReferenceError: Cannot access 'a' before initialization
{ a; console.log(a); let b; } // ReferenceError: a is not defined

Is the different textual error description the only meaningful way to observe the hoisting in userland?


Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>