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();
-
DVR
LFA TV
1 day agoThe Soon-Coming Social Millennium | TRUMPET DAILY 1.13.25 7pm
4.96K -
1:00:03
Sarah Westall
1 hour agoWeaponized Chaos – Worst in Modern History; Changing Geopolitical Landscape w/ Andy Schectman
2.43K -
LIVE
SpartakusLIVE
2 hours ago#1 Hacker/Scammer PLUNGES into CRYPTO || !crypto !spartacoin
217 watching -
53:15
Kimberly Guilfoyle
5 hours agoCalifornia Residents Demand Answers, Live with Rep Vince Fong, Mike Davis, and Paul Peterson | Ep. 188
40.8K56 -
1:49:51
Redacted News
5 hours agoEMERGENCY! 10 MILLION UNDER FIRE WARNING & 100 MPH WINDS, NEWSOM UNVEILS CALIFORNIA 2.0 PLAN
125K177 -
49:33
Candace Show Podcast
4 hours agoI Respond To Mr. And Mr. Macron | Candace Ep 131
99.6K276 -
1:58:04
Revenge of the Cis
6 hours agoEpisode 1429: Catch And Release
37.4K4 -
2:00:01
Film Threat
10 hours agoVERSUS: HOLLYWOOD IS STILL ON FIRE | Film Threat Versus
22K1 -
12:33
Silver Dragons
5 hours agoSilver Price Crushed Today - NEW TREND STARTING?
20.2K2 -
1:02:03
In The Litter Box w/ Jewels & Catturd
23 hours agoRecall Newscum & Bass! | In the Litter Box w/ Jewels & Catturd – Ep. 718 – 1/13/2025
97.2K36