My classes are structured as follows:
class FilterWeekScheduleClass {
}
class FilterClassJournal {
}
const registryFilterClasses = {
FilterWeekScheduleClass,
FilterClassJournal
};
class SingletonClassRegister {
public registeredClasses = {};
public constructor() {
for (let obj in registryFilterClasses) {
// CREATE INSTANCE OF obj LIKE new obj();
}
}
}
let a = new SingletonClassRegister();
When creating instances in the constructor of the SingletonClassRegister
class based on registryFilterClasses
, how should I properly create instances?
I attempted the following approach:
class SingletonClassRegister {
public registeredClasses = {};
public constructor() {
for (let obj of registryFilterClasses) {
registryFilterClasses[obj.constructor.name] = new obj();
}
}
}
Is this the correct way to do it?