How to call a static subclass method in JavaScript
<p>How can I call a static method of a subclass from a static method of the parent class?</p>

<pre><code>class A {

  static foo(){
    // call subclass static method bar()
  }
}

class B extends A {

  static bar(){
    // do something
  }
}

B.foo()
</code></pre>

<p><strong>Update</strong>: </p>

<p>The reason why I tried this is that subclasses of A would have worked best as singletons in my context and I wanted to use the <a href="https://en.wikipedia.org/wiki/Template_method_pattern" rel="nofollow">template method pattern</a> in A.</p>

<p><s>Since it looks like I cannot get a reference to a subclass from a static context</s> I am now exporting instances of subclasses of A which works just as well. Thanks.</p>

<p><strong>Update 2</strong></p>

<p>Yes, it is a duplicate to a degree (the other question does not involve  subclassing). The reference, even from a static context, is <code>this</code>. So this works:</p>

<pre><code>static foo(){
    this.bar();
}
</code></pre>