I was more looking for the rationale behind it. I know it currently
doesn't hoist.

On Thu, Oct 16, 2014 at 8:55 PM, Domenic Denicola
<[email protected]> wrote:
> https://www.google.com/search?q=class+declarations+hoisted+site%3Aesdiscuss.org
>  leads to 
> https://esdiscuss.org/topic/in-es6-strict-mode-do-function-declarations-within-a-block-hoist
>  as the first result which lays it out pretty clearly.
>
> -----Original Message-----
> From: es-discuss [mailto:[email protected]] On Behalf Of Isiah 
> Meadows
> Sent: Thursday, October 16, 2014 20:53
> To: [email protected]
> Subject: Unhoisted class declarations
>
> I know it was touched on a recent thread 
> (https://esdiscuss.org/topic/a-new-es6-draft-rev28), but is there a reason 
> why class declarations aren't hoisted like function declarations? It is a 
> little confusing to be to type (1) but not (2).
>
> (1)
> ```js
> foo(); // prints "Yay!"
>
> function foo() {
>   console.log('Yay!');
> }
> ```
>
> (2)
> ```js
> new Foo().speak(); // Error
>
> class Foo {
>   constructor() {}
>
>   speak() {
>     console.log('Yay!');
>   }
> }
> ```
>
> --
> Isiah Meadows
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss



-- 
Isiah Meadows
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to