I have a abstract base class that controls a lot of the heavy lifting for subclasses, and I want to add a static factory method to insatiate the object that would work in a similar way to PHP's static
keyword.
I am currently calling the abstract classes static method and passing it a constructor of a subclass type: Subclass.fromFile({}, Subclass)
, which is so elegant.
Current Implementation
class AbstractClass {
//...
static fromFile(attributes, constructor) {
return new constructor(attributes)
}
//...
}
Is there a JS equivalent to PHP's new static()
?