title: Javascript classes : how to access overridden parent class functions in parent class code
body: <p>Javascript ES6 ( node 8.4.0 and latest chrome and recent Firefox )</p>
  
  <p>I expected </p>
  
  <pre><code>class Parent {
      init(){
          console.log("Parent init") ;
          this._surname = "McClass" ;
      }
      constructor() {
          console.log("Parent constructor") ;
          this.init();
      }
  
      get surname(){
          return this._surname ;
      }
  }
  
  class Child extends Parent {
  
      init(){
          console.log("Child init") ;
      }
      constructor() {
          super();
          console.log("Child constructor") ;
          this.init();
      }    
  }
  
  var child = new Child() ;
  
  console.log(child.surname);
  </code></pre>
  
  <p>to give the following output;</p>
  
  <pre><code>Parent constructor
  Parent init
  Child constructor
  Child init
  McClass
  </code></pre>
  
  <p>(which is what comparable C++ code gives)</p>
  
  <p>Alas, I got this ;</p>
  
  <pre><code>Parent constructor
  Child init
  Child constructor
  Child init
  undefined
  </code></pre>
  
  <p>Am I doing something wrong or is this the correct intended behaviour and if so how is it justified ?</p>
  
  <p><strong>EDIT;</strong></p>
  
  <p>See MinusFour's answer below on how to achieve what I was trying to do / expecting.</p>
  
  <p>As to why the observed output is the "correct" behaviour and justified ;</p>
  
  <p>As Bergi pointed out (in comments) all calls to object methods in js are effectively "virtual" (the last method of that name added to the object's prototype inheritance chain being the first found and hence executed). It turns out calls are still effectively virtual in a class construction context.</p>
  
  <p>C++ does not apply virtual method behaviour during construction but then again Java does and you get the same output (as above) in comparable Java code so there is a precedent for the observed behaviour.</p>