You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The scope of a variable declared with <code>let</code> is its innermost enclosing block statement, loop or
function. Unlike variables declared with <code>var</code>, variables declared with <code>let</code> are not
hoisted to the top of their scope, giving rise to a region of code where the variable is in scope, but not
declared yet. Accessing a <code>let</code>-bound variable inside this so-called "temporal dead zone"
is permitted by some legacy implementations, but is illegal in ECMAScript 2015.
</p>
</overview>
<recommendation>
<p>
Move the <code>let</code> declaration to the beginning of its scope.
</p>
</recommendation>
<example>
<p>
In the following example, <code>x</code> is initialized before its declaration:
</p>
<samplesrc="examples/TemporalDeadZone.js" />
<p>
The declaration should be moved as follows:
</p>
<samplesrc="examples/TemporalDeadZoneGood.js" />
</example>
<references>
<li>Mozilla Developer Network: <ahref="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let">Temporal dead zone and errors with let</a>.</li>