tc39 / proposal-private-methods

Private methods and getter/setters for ES6 classes
https://arai-a.github.io/ecma262-compare/?pr=1668
345 stars 37 forks source link

Are properties defined after private methods? #17

Closed jridgewell closed 7 years ago

jridgewell commented 7 years ago
class Foo {
  publicField = this.#foo()
  #privateField = this.#foo();

  #foo() {
  }
}

I imagine, like prototype methods, private "own" methods are defined before properties are evaluated? So it'd be something like:


class Foo {
  constructor() {
    super();
    // define private methods
    // define properties

    // user code
  }
}
littledan commented 7 years ago

Yes, they are, for exactly that reason. See InitializeInstanceElements--first methods are added, then fields. Same goes for static.

jridgewell commented 7 years ago

Prefect, looks like I missed that since there weren't any changes to the algorithm (I was scanning for green and red).

littledan commented 7 years ago

Oh yeah new abstract algorithms don't have any green in them. It's just all new.