I have a class name and want to use it to create a class instance dynamically. How can I do that?
class FieldText {
constructor() {
console.log('hello text field');
}
}
class FieldTextarea {
constructor() {
console.log('hello textarea field');
}
}
function callField(name) {
new FieldText(); // Somehow use name variable instead to make it dynamic
// new Field${name}(); // Does not work
}
callField('text');