I'm new to JavaScript and I'm trying to achieve the logic I have commented in the constructor method of the base class
export default class Building {
constructor(sqft) {
this._sqft = sqft;
// when a subClass extends from this class
// and does not implement `certainMethod()`, throw an error.
// this should happen only when `subClass extends baseClass` and not with `new` keyword
// object creation.
}
}
subClass extends baseClassand not withnewkeyword object creation."? That theclass SubBuilding extends Building {}statement itself throws the error? Or thatnew SubBuilding()call should throw the error, but instantiatingnew Building()should still be allowed?