Unhoisted class declarations

# Isiah Meadows (11 years ago)

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!');
  }
}
# Domenic Denicola (11 years ago)
# Isiah Meadows (11 years ago)

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

# Claude Pache (11 years ago)

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?

# Allen Wirfs-Brock (11 years ago)

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