title: TypeScript: Getting a class/constructor of the object at runtime
body: <p>For debugging purposes, I want a <code>toString()</code> method of an abstract class to print of which subclass the instance actually is.</p>
  
  <pre><code>abstract FrameModel {
      ...
      public toString() {
          var classOfThis = ?????;
          return `FrameModel&lt;${classOfThis}&gt;#${this.vertexId}`;
      }
  }
  </code></pre>
  
  <p>Also it would be great if I could use that class in TypeScript to access the <code>static</code> members; in other words, if I got the JavaScript constructor function to which TypeScript puts the <code>static</code> fields.</p>
  
  <p>I've tried </p>
  
  <pre><code>var classOfThis = Object.getPrototypeOf(this).constructor;
  </code></pre>
  
  <p>But that's not it :)</p>