The JavaScript SUPER keyword is super! 🦸‍♂️

Поделиться
HTML-код
  • Опубликовано: 20 янв 2025

Комментарии • 22

  • @BroCodez
    @BroCodez  Год назад +7

    // super = keyword is used in classes to call the constructor or
    // access the properties and methods of a parent (superclass)
    // this = this object
    // super = the parent
    class Animal{
    constructor(name, age){
    this.name = name;
    this.age = age;
    }
    move(speed){
    console.log(`The ${this.name} moves at a speed of ${speed}mph`);
    }
    }
    class Rabbit extends Animal{
    constructor(name, age, runSpeed){
    super(name, age);
    this.runSpeed = runSpeed;
    }
    run(){
    console.log(`This ${this.name} can run`);
    super.move(this.runSpeed);
    }
    }
    class Fish extends Animal{

    constructor(name, age, swimSpeed){
    super(name, age);
    this.swimSpeed = swimSpeed;
    }
    swim(){
    console.log(`This ${this.name} can swim`);
    super.move(this.swimSpeed);
    }
    }
    class Hawk extends Animal{

    constructor(name, age, flySpeed){
    super(name, age);
    this.flySpeed = flySpeed;
    }
    fly(){
    console.log(`This ${this.name} can fly`);
    super.move(this.flySpeed);
    }
    }
    const rabbit = new Rabbit("rabbit", 1, 25);
    const fish = new Fish("fish", 2, 12);
    const hawk = new Hawk("hawk", 3, 50);
    rabbit.run();
    fish.swim();
    hawk.fly();

    • @amirkangarloo-v5h
      @amirkangarloo-v5h Год назад

      Thanks 👍

    • @sfspmusic
      @sfspmusic 11 месяцев назад

      Bro, are use sure we need super for the move method?

  • @willhampshire2415
    @willhampshire2415 Год назад +6

    Goat of RUclips programming tutorials

  • @scheeseb
    @scheeseb 7 месяцев назад +4

    This cleared up extending classes as a whole. This is what I want from coding tutorials. Just show me the moving parts moving,! Don't just repeat the same buzzwords as you plow through convoluted examples.

  • @omar.abuissa
    @omar.abuissa Год назад +3

    So I know that this comment don't relate to this video but realy thank you for learning me C#, and I'm writing this comment directly after I finish your course so really thank you too much. ♥

  • @hunin27
    @hunin27 Год назад +1

    Thanks for the video bro!
    Lots of love ❤

  • @piotrmazgaj
    @piotrmazgaj 5 месяцев назад

    This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal.

  • @noemil6036
    @noemil6036 Год назад +1

    Many thanks, great explanation

  • @Teal_Nameera_Gacha_Offical
    @Teal_Nameera_Gacha_Offical Год назад

    Thanks dude! I really needed this!

  • @nidarag_e_Balochistan
    @nidarag_e_Balochistan 3 месяца назад

    where have you been, why youtube did not show me any of your videos! But till now your channel is in my subscription. thank for such an explanation.

  • @Keyra_Ren
    @Keyra_Ren 10 месяцев назад

    Thank you, its really clear!

  • @BluePaneTechnologies-nu4hh
    @BluePaneTechnologies-nu4hh 4 месяца назад

    great example great explanation

  • @SleepyGhst
    @SleepyGhst 11 месяцев назад

    solid explanation of super()

  • @shashankatole6968
    @shashankatole6968 Год назад +1

    do you mean this is inheritance? nice explanations👌

  • @Belladonna_khaday
    @Belladonna_khaday 5 месяцев назад

    Thank you so much Bro❤❤

  • @LizyAd
    @LizyAd 9 месяцев назад

    Thank you so much!!

  • @ibrahimhossen6549
    @ibrahimhossen6549 7 месяцев назад

    ❤❤❤

  • @NicolasMoryson
    @NicolasMoryson Год назад +1

    hey could you do a tut for a login page with data bank?with install setup and everything

  • @karem_darwesh
    @karem_darwesh 6 месяцев назад

    Thanks greate explanation

  • @Podcast.4.Moments
    @Podcast.4.Moments 11 месяцев назад

    Thanks

  • @hunin27
    @hunin27 Год назад

    just 6 views???