class Shape {}
let myClass = 'Shape';
new myClass();
This looks for a class myClass
and fails, I have no idea how to get it to try and create a Shape
class.
In PHP it would be simple:
class Shape {}
$myClass = 'Shape';
new $myClass();
How can I do this in JavaScript?
I've tried new window[myClass]()
, it doesn't work with ES6 classes.