I want to create an instance of child class from a static method in a base class
class Base {
static find(id) {
const attributes = database.get(id);
return new getChildClass(attributes);
}
}
class FirstChild extends Base {
}
class SecondChild extends Base {
}
I want FirstChild.find(1)
to return an instance of FirstChild
and
SecondChild.find(1)
to return an instance of SecondChild
Is in possible to achieve this in node JS?