I need to create a new class objects in loop where I can provide a dynamic name of this class, e.g. I have class "tree":
export default class ParentClass {
// ...
}
export default class Thomas extends ParentClass {
// ...
}
export default class Paul extends ParentClass {
// ...
}
and loop:
const workers = ['Thomas', 'Paul'];
for (const worker of workers) {
const h = new <worker>();
// do something with this object
}
Is it possible to do this? Project using NodeJS with Express.js.
workers-array correspond to an existing class?