Hoisting behaviour of 'const' and 'let'

YR Chen maian330 at gmail.com
Sun Oct 12 18:36:03 PDT 2008

On Sun, Oct 12, 2008 at 5:27 PM, David-Sarah Hopwood <
david.hopwood at industrial-designers.co.uk> wrote:

> Alternatively, if the program is completely known in advance, then it
> can be fully processed for function declarations, but in that case it is
> statically invalid because f is referenced outside its scope.

My example assumes that this is in a single script, so the function
definition is hoisted to the top. But you're not still not following the
example properly. How can a syntax analyzer determine that f is being
referenced in that example? f is being recalled as a property of the global
object. Given the following:

// y is dynamically set to 'f'
g = this[y];  // g is now f
const x = 10;
function f() { ... x ... }

how can you determine that g refers to f via static analysis?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20081012/62065959/attachment.html 

More information about the Es-discuss mailing list