The JavaScript SUPER keyword is super! π¦ΈββοΈ
Bro Code
@brocodezAbout
Coding bootcamps HATE HIM! πΏ
Latest Posts
Video Description
00:00:00 intro 00:00:22 setup 00:02:39 super constructor 00:05:59 super methods 00:09:03 conclusion // 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();
You May Also Like
Boost Your Coding Skills Today
AI-recommended products based on this video

30 Pack Multicolor Pen in One Easter Party Favors 6-in-1 Fun Pens 6 Colors Cute Pens Easter Classroom Gifts Retractable Ballpoint Pen for Birthday Gifts, Student Rewards, Class Prizes

Zhanmai Open When Envelopes for College Student, Going Away to College Gifts University Gift Card Book, High School Care Package, Birthday Cash Card Holder for Daughter Son Friends Gift(Pastel)




















