title: Is there a way to access superclass variables in subclass with JavaScript?
body: <p>I was learning JavaScript oops with some sample example when I came across to access superclass methods in subclass which is possible with super keyword
  but when I try to access or return a variable of super class it returns undefined or the sub class variable I tried in various way to get variable</p>
  
  <p>I have also gone <a href="https://stackoverflow.com/questions/14312921/javascript-polymorphism-variable-inheritance">this</a> Stack Overflow post.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class dad {
      constructor(name) {
          this.name = name;
      }
      printname() {
          console.log(this.name);
          var a = 2;
          return a;
      }
      sendVal() {
          console.log(this.name);
          var a = 2;
          return this.name;
      }
  }
  
  class son extends dad {
      constructor(name) {
          super(name);
      }
      printname() {
          console.log(super.printname());
  
      }
      printvariable() {
          console.log(super.name);
  
      }
      getvalue() {
          console.log(super.sendVal())
      }
  }
  
  var o1 = new dad('jackson');
  var o2 = new son('jack')
  
  o1.printname()
  o2.printname()
  o2.printvariable()
  o2.getvalue()</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  </code></pre>
  </div>
  </div>
  </p>