Answer the question
In order to leave comments, you need to log in
How to create objects dynamically in JavaScript?
I know this way:
var classname = "Number";
var num1 = eval(`new ${classname}()`);
Answer the question
In order to leave comments, you need to log in
new (window || global)[className](); // window в браузерах, global в node
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question