🔰inheritance
// in any method definition
super.prop // parent's property
super[expr] // (same)
// ⭐️ subclass
class B extends A {
// ⭐️ subclass constructor
// (if omitted, a default constructor is created automatically)
constructor(...args) {
// ⭐️ must call super() before referencing `this`
super(...args) // ⭐️ superclass constructor
// intialize `this` ...
}
// override method
method() {
super.method() // ⭐️ call parent's method (optional)
// ...
}
}Last updated