I have some ES2015 classes and need to produce object by one of them in my function.
I get class name as string. How can I do this?
Now I am using switch … case
, but it look monstrous, you know.
let classname = 'MyClass';
new window[classname](); // TypeError: window.MyClass is not a constructor
Is it here a more nice way?