title: JavaScript new this.constructor(); => SyntaxError: missing ] after element list
body: <p>I have some classes:</p>
  
  <pre><code>class Sample{
      static createSelf() {
          return new this.constructor(1, 2);
      }
  }
  
  class AnotherClass extends Sample {
      constructor(a, b) {
          this.c = a+b;
      }
  }
  
  ac = AnotherClass.createSelf();
  </code></pre>
  
  <p>How do I do this? </p>
  
  <p>This concrete example gives me <code>SyntaxError: missing formal parameter</code>, although in my original code (500 lines), when I have <code>new this.constructor()</code>, I get <code>SyntaxError: missing ] after element list</code> pointed at the first line (the formal parameter error is pointed at line 1, too). I know it is because of this line, as when I replace it with a normal class name, it works. There is no Array initialization close. The error cannot possibly mean:</p>
  
  <blockquote>
    <p>There is an error with the array initializer syntax somewhere. Likely there is a closing bracket ("]") or a comma (",") missing.</p>
  </blockquote>
  
  <p>from 
  <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_list" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_bracket_after_list</a></p>
  
  <p>UPDATE
  original code:</p>
  
  <pre><code>class Participant {
      constructor(origin, destination, number, startDate, endDate) {
          ...
      }
  
      static restore(save) {
          const participant = new this.constructor(
              new Marker(save.originLocation, this.getMarkerOptions(true, save.isDriver, save.number)).addTo(map),
              new Marker(save.destinationLocation, this.getMarkerOptions(false, save.isDriver, save.number)).addTo(map),
              save.number,
              save.startDate,
              save.endDate
          );
  
          return participant;
      };
  }
  
  class Driver extends Participant {}
  
  d = Driver.restore(saveObject);
  </code></pre>