Learn JavaScript INHERITANCE in 7 minutes! 🐇

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2023
  • // inheritance = allows a new class to inherit properties and methods
    // from an existing class. Helps with code reusability
    class Animal{
    alive = true;
    eat(){
    console.log(`This ${this.name} is eating`);
    }
    sleep(){
    console.log(`This ${this.name} is sleeping`);
    }
    }
    class Rabbit extends Animal{
    name = "rabbit";
    run(){
    console.log(`This ${this.name} is running`);
    }
    }
    class Fish extends Animal{
    name = "fish";
    swim(){
    console.log(`This ${this.name} is swimming`);
    }
    }
    class Hawk extends Animal{
    name = "hawk";
    fly(){
    console.log(`This ${this.name} is flying`);
    }
    }
    const rabbit = new Rabbit();
    const fish = new Fish();
    const hawk = new Hawk();
    console.log(rabbit.alive);
    rabbit.eat();
    rabbit.sleep();
    rabbit.run();

ความคิดเห็น • 18

  • @BroCodez
    @BroCodez  9 หลายเดือนก่อน +4

    // inheritance = allows a new class to inherit properties and methods
    // from an existing class (parent -> child)
    // helps with code reusability
    class Animal{
    alive = true;
    eat(){
    console.log(`This ${this.name} is eating`);
    }
    sleep(){
    console.log(`This ${this.name} is sleeping`);
    }
    }
    class Rabbit extends Animal{
    name = "rabbit";
    run(){
    console.log(`This ${this.name} is running`);
    }
    }
    class Fish extends Animal{
    name = "fish";
    swim(){
    console.log(`This ${this.name} is swimming`);
    }
    }
    class Hawk extends Animal{

    name = "hawk";
    fly(){
    console.log(`This ${this.name} is flying`);
    }
    }
    const rabbit = new Rabbit();
    const fish = new Fish();
    const hawk = new Hawk();
    console.log(rabbit.alive);
    rabbit.eat();
    rabbit.sleep();
    rabbit.run();

  • @ArinAkaMazu
    @ArinAkaMazu 8 หลายเดือนก่อน +14

    Yo bro seriously how do you manage to be such a goat like lord I fricking love your tutorials you make everything look so easy

  • @SuperFastJewJitsu
    @SuperFastJewJitsu 8 หลายเดือนก่อน +4

    Don't have time to watch as I'm heading out but had to instalike,
    Keep at it bro.

  • @speroakpo4630
    @speroakpo4630 7 หลายเดือนก่อน +1

    Amazing job man!

  • @SimpleAverageBoi69
    @SimpleAverageBoi69 8 หลายเดือนก่อน +3

    Bro bro bro u a legend ❤❤❤❤❤❤❤

  • @Gigglesaintlame
    @Gigglesaintlame 8 หลายเดือนก่อน +2

    ❤ waiting for more videos Bro(fourth day)

  • @miranda4923
    @miranda4923 3 หลายเดือนก่อน

    Very much good 😂!

  • @realitybeckons4120
    @realitybeckons4120 8 หลายเดือนก่อน +1

    Thank you

  • @helioobianchi
    @helioobianchi 4 หลายเดือนก่อน

    I'm wondering if dev tools have validation features for code inconsistencies like calling a method that doesn't exist or trying to use an unexisting variable/attribute (is there a vscode extension for this?). in Java for example those are detected in compile time, i.e. you need to fix them to get to run the code (the IDE also warns about them to help save time)

  • @sanjay9970
    @sanjay9970 5 หลายเดือนก่อน +1

    excellent explanation

  • @Abde473
    @Abde473 2 หลายเดือนก่อน

    thanks bro 😂

  • @RedHeadphones
    @RedHeadphones 8 หลายเดือนก่อน +1

    bro, can you make a video on hashmaps

  • @manojpatra4458
    @manojpatra4458 หลายเดือนก่อน

    Nice explanation. However, I wonder why you didn't use constructor in any of the classes. Will anything get changed with constructors in inheritance?

  • @navnitkhandait6750
    @navnitkhandait6750 5 หลายเดือนก่อน +1

    really a true bro code

  • @malikgulraiz3659
    @malikgulraiz3659 8 หลายเดือนก่อน +2

    We want react js tutorials
    👇

  • @PrAvEeN.__.
    @PrAvEeN.__. 8 หลายเดือนก่อน

    Bro make a tutorial to download the Java for full stack developer in laptop
    Asking for sis

  • @user-ej4vt2vg4o
    @user-ej4vt2vg4o 19 วันที่ผ่านมา

    bro please teach us typeScript