Unhoisted class declarations
www.google.com/search?q=class+declarations+hoisted+site%3Aesdiscuss.org leads to esdiscuss.org/topic/in-es6-strict-mode-do-function-declarations-within-a-block-hoist as the first result which lays it out pretty clearly.
I was more looking for the rationale behind it. I know it currently doesn't hoist.
Le 17 oct. 2014 à 08:54, Isiah Meadows <impinball at gmail.com> a écrit :
I was more looking for the rationale behind it. I know it currently doesn't hoist.
In the discussion pointed by Domenic, it is explained why classes don't hoist (namely, in order to avoid premature evaluation of the extends
clause).
Is something not clear?
On Oct 17, 2014, at 12:52 AM, Claude Pache wrote:
Le 17 oct. 2014 à 08:54, Isiah Meadows <impinball at gmail.com> a écrit :
I was more looking for the rationale behind it. I know it currently doesn't hoist.
In the discussion pointed by Domenic, it is explained why classes don't hoist (namely, in order to avoid premature evaluation of the
extends
clause). Is something not clear?
and also computed property name expressions
I know it was touched on a recent thread (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)
foo(); // prints "Yay!" function foo() { console.log('Yay!'); }
(2)
new Foo().speak(); // Error class Foo { constructor() {} speak() { console.log('Yay!'); } }