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();
-
19:54
Forrest Galante
2 days agoPrivate Tour Of America's Best Marine Animal Facility
73.5K9 -
2:59:11
Side Scrollers Podcast
19 hours agoDEI’s FINAL BOSS EXPOSED + Book Publisher REVERSES Cancel Attempt + More | Side Scrollers
54.2K19 -
23:00
The Pascal Show
10 hours ago $1.75 earnedCANDACE EXPOSES TEXTS! Candace Owens Shows Proof Charlie Kirk Was B*llied By Donors Before His Death
7.69K5 -
1:31:37
The HotSeat
14 hours agoBondi On The Hill + Equitable Grading? We Are Failing Our KIDS!
30.8K6 -
6:05
Spooky Grandpa's Scary Stories
1 month agoTHE HARVEST MAN (Halloween, Horror, Folklore, Supernatural, Paranormal)
9.01K7 -
LIVE
Lofi Girl
2 years agoSynthwave Radio 🌌 - beats to chill/game to
242 watching -
1:02:11
DeVory Darkins
13 hours ago $37.80 earnedDemocrats suffers ANNIHILATION during heated hearing with Bondi as Jack Smith bombshell drops
160K110 -
3:00:07
Price of Reason
13 hours agoJoe Rogan & Theo Von TURN on Trump? Hollywood to STOP Lecturing Viewers? Ghost of Yotei FIASCO!
62.7K9 -
4:49
Russell Brand
16 hours agoThis is Unbelievable...
68.8K71 -
2:55:33
Badlands Media
16 hours agoDEFCON ZERQ Ep. 012: Featuring "AND WE KNOW" and a Special Guest
68.4K67