super in Static Methods
You'll learn how to use super inside static methods to call the parent class's static methods—just like you do with instance methods, but at the class level.
What Are Static Methods Again?
Static methods belong to the class itself, not to instances. You call them directly on the class: MyClass.staticMethod(). When you inherit from a parent class, child classes can override static methods too.
Calling Parent Static Methods with super
Just as you use super.methodName() to call a parent's instance method from a child's instance method, you can use super.staticMethodName() inside a child's static method to call the parent's static method.
class Animal {
static classify() {
return "Living organism";
}
}
class Dog extends Animal {
static classify() {
const parentClassification = super.classify();
return `${parentClassification} → Mammal → Canine`;
}
}
console.log(Dog.classify());
// "Living organism → Mammal → Canine"
Why This Matters
Without super, you'd have to reference the parent class by name (Animal.classify()), which creates tight coupling. Using super keeps your code flexible—if you later change the parent class, the child doesn't need updates.
class Bird extends Animal {
static classify() {
// Extends parent's classification
return super.classify() + " → Avian";
}
}
console.log(Bird.classify());
// "Living organism → Avian"
Think of super in static methods as a "call upstairs"—you're asking the parent class for its static behavior, then building on top of it.
Key Takeaway: Use super.staticMethodName() inside a child class's static method to invoke the parent class's static method, enabling extensible class-level behavior without hardcoding parent class names.