0
 class Derived4 extends Base2 {
   constructor (a) {
      this = Object.create(new^.prototype);
      this.a = a;
    }
  isDerived4() {return true};
}

This is a code from Github site but I don't understand why the first argument of the Object.create(proto) is new^.prototype

  • The writer is talking about a derive class in Js that does not use it super class constructor ... the source of this code is https://gist.github.com/allenwb/53927e46b31564168a1d – Emmanuel B. Dorbor Jr Jan 05 '21 at 19:42
  • 1
    If you search the page you linked for `new^`, the first result and onwards explains this suggested syntax. I'm not aware of any environment that actually supports it. – Etheryte Jan 05 '21 at 19:45
  • 2
    This isn't answerable without the context, that's *not* just JavaScript. But see point 6 of https://gist.github.com/allenwb/53927e46b31564168a1d#constructor-semantics-summary – jonrsharpe Jan 05 '21 at 19:45
  • @Etheryte it *is* just a proposal. It might never be supported or might get changed a lot by the time it's accepted. – VLAZ Jan 05 '21 at 19:52
  • 2
    @VLAZ Actually, it *was* a proposal more than 6 years ago, and has since been implemented in ES6. The `new^` token became [what is `new.target` now](https://stackoverflow.com/q/32450516/1048572) – Bergi Jan 05 '21 at 20:03

0 Answers0