Isiah Meadows
2014-10-17 00:52:36 UTC
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!');
}
}
```
(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
Isiah Meadows