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();
-
21:33
marcushouse
4 hours ago $0.81 earnedSpaceX Just Revealed the Plan for Starship Flight 11! 🚀
10K4 -
35:03
Clownfish TV
7 hours ago'Live by the Sword, Die by the Sword.' | Clownfish TV
16.9K51 -
8:15
Sideserf Cake Studio
2 hours ago $0.19 earnedA Hyperrealistic TAKIS Cake?
10.9K1 -
55:49
SGT Report
14 hours agoFAKED TRAGEDY, LONE GUNMAN OR PATSY? -- Jeffrey Prather
32.2K131 -
9:30
Adam Does Movies
13 hours ago $0.21 earnedThe Long Walk - Movie Review
8.87K2 -
2:28
WildCreatures
14 days ago $0.91 earnedNature's struggle for survival: Water snake devours mudpuppy
12.4K3 -
1:07
Memology 101
14 hours ago $0.39 earnedEric Swallowswell compares January 6th to 9/11 and Pearl Harbor
7.85K16 -
24:21
Uncommon Sense In Current Times
19 hours ago $10.66 earnedA Revolution of Virtue | Charlie Kirk on Beating the Woke, Faith & Saving the West
40.1K28 -
33:17
Homesteading Family
4 hours agoThe End of The Pantry Chat
26.9K8 -
18:42
Nicholas Bowling
18 hours ago $5.66 earnedCharlie Kirk Martyred – A Christian's Response
36.7K39