In ES6 strict mode: do function declarations within a block hoist?

John Lenz concavelenz at gmail.com
Thu Jun 5 15:09:28 PDT 2014


Thanks.


On Thu, Jun 5, 2014 at 8:54 AM, Andreas Rossberg <rossberg at google.com>
wrote:

> On 5 June 2014 17:44, John Lenz <concavelenz at gmail.com> wrote:
> > That is to say, is this valid:
> >
> > if (x) {
> >   f();
> >   function f() { doSomething() }
> > }
> >
> > The same question applies to class declarations.  I assume that top level
> > class declarations hoist. (Where is this in the spec?)
>
> Yes, that is valid. Function bindings are initialised when entering a
> scope, all other declarations when their respective statement is
> executed -- before that any access will cause a ReferenceError (the
> so-called temporal dead zone).
>
> In particular, classes don't "hoist", because their extends clause has
> to be evaluated at the right point in time.
>
> /Andreas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140605/78f00a2a/attachment.html>


More information about the es-discuss mailing list