๐Ÿ”ฐinheritance

JS โŸฉ value โŸฉ object โŸฉ class โŸฉ 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