I'm trying to access static method baseArea from parent class cars but it shows following error:
test.php:34 Uncaught TypeError: (intermediate value).baseArea is not a function
at Bike.get bikeArea [as bikeArea] (test.php:34)
at test.php:42
But it works fine when I use baseArea () {} instead of static baseArea() {}
What am I doing wrong?
class Cars {
constructor(x, y) {
this.height = x;
this.width = y;
}
static baseArea() {
return 44;
}
}
class Bike extends Cars {
constructor(flag) {
super(flag, flag);
}
get bikeArea() {
return super.baseArea();
}
}
let bike = new Bike(10);
console.log(bike.bikeArea);
super.baseArea()should beCars.baseArea().Bike.baseArea()superHow's that working?pingpongmethod is also static AND called withComputer.pingpong()and notnew Computer().pingpong()The whole chain is static. Maybe in that circumstances it succeed to resolve the super.