Welcome Guest, Not a member yet? Register   Sign In
How does this work: super()

Hello gentlemen!
I have been working with classes, and now I run into class prototyping! I understand what it does, (super() refers to the parent class and allows the child class to access the parent’s methods and properties) but I do not understand how it works or what it means. Why would you need access to the parent’s properties name and width for the child class? Spudnik is not calling on the parent class, but the PotatoPlanet class. I don’t understand it. The class below extends another class. (You can check chapter 20 for the parent class).

    class PotatoPlanet extends Planet {
        constructor(name, width, potatoType) {
            super(name, width);
            this.potatoType = potatoType;
        getPotatoType() {
            let thePotato = this.potatoType.toUpperCase() + "!!l!!!";
            return thePotato;
    let spudnik = new PotatoPlanet("Spudnik", 12411, "Russet");
    spudnik.gravity = 42.1;
Today Is Name, Tomorrow Is Legend! 

Best CRM Software in India

Theme © iAndrew 2016 - Forum software by © MyBB