1

I would like to be able to do something like this:

let className = 'Person';
return new [className](data);

However this gives the following error:

TypeError: "[...] is not a constructor"

I have defined the class using the class keyword, as follows:

class Person extends Entity {...}
DatsunBing
  • 8,684
  • 17
  • 87
  • 172
  • 1
    Does this answer your question? [Create object from string in JavasScript ECMAScript 6](https://stackoverflow.com/questions/31776949/create-object-from-string-in-javasscript-ecmascript-6) – palaѕн Apr 03 '20 at 08:40

0 Answers0