Hoisting behaviour of 'const' and 'let'
david.hopwood at industrial-designers.co.uk
Sat Oct 11 21:02:45 PDT 2008
David-Sarah Hopwood wrote:
> What is proposed to be hoisted in the case of 'const' and 'let' is just
> the point at which the variable's *scope* begins. But, unlike the case
> of function definitions, this in general extends the scope to a point
> where the variable has not been initialized. If 'const' and 'let' (with
> an initializer) were not hoisted, then there could be a static guarantee
> that the variable will have been initialized at every point at which it
> is in scope. By hoisting the scope, we're effectively throwing away the
> possibility of such a guarantee -- at least if we want to avoid a much
> more complicated static analysis.
This would also mean that we cannot have any types that do not include
the value 'undefined' (either primitive types, or "non-nullable" reference
More information about the Es-discuss