Premium Only Content
The JavaScript SUPER keyword is super! 🦸♂️
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();
-
14:45
Mrgunsngear
1 day ago $98.73 earnedFletcher Rifle Works Texas Flood 30 Caliber 3D Printed Titanium Suppressor Test & Review
81.6K21 -
17:17
Lady Decade
1 day ago $6.12 earnedMortal Kombat Legacy Kollection is Causing Outrage
54.8K9 -
35:51
Athlete & Artist Show
1 day ago $11.13 earnedIs Ryan Smith The Best Owner In The NHL?
75.8K6 -
22:56
American Thought Leaders
2 days agoCharles Murray: I Thought Religion Was Irrelevant to Me. I Was Wrong.
64.6K31 -
36:22
Brad Owen Poker
11 hours agoGIGANTIC $17,000+ Pot In BOBBY’S ROOM! TRAPPING Top Pro w/FULL HOUSE!! Big Win! Poker Vlog Ep 326
66K3 -
3:53
GreenMan Studio
1 day agoRUMBLE RUNDOWN: DREAM HACK SPECIAL W/Greenman Reports
58.3K10 -
1:28
Damon Imani
2 days agoThey Laughed at Trump’s Cognitive Test — Damon Made Them REGRET It!
54.2K37 -
9:14
Freedom Frontline
1 day agoAdam Schiff PANICS As Eric Schmitt Exposes His Dirty Lies LIVE
36.2K80 -
10:32
GBGunsRumble
1 day agoGBGuns Armory Ep 153 Adler Arms AD-9`
24.2K2 -
35:53
Degenerate Plays
10 hours ago $1.06 earnedRuckus Randy And Repair Ronald (Socks On) - Call of Duty: Modern Warfare 2 (2009) : Part 7
16.3K2