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();
-
LIVE
DLDAfterDark
2 hours agoIt's SHTF! Do You Have What You Need?? Let's Review Items & Priorities
123 watching -
28:58
Stephen Gardner
3 hours ago🚨Explosive allegations: Rosie O’Donnell connects Trump to Epstein scandal!?
4.54K33 -
LIVE
SavageJayGatsby
1 day agoSpicy Saturday | Let's Play: Grounded
526 watching -
2:06:27
MattMorseTV
5 hours ago $37.17 earned🔴Vance just went SCORCHED EARTH.🔴
110K147 -
46:41
The Mel K Show
9 hours agoMel K & Corey DeAngelis | The Hopelessly Captured Teacher’s Unions: Biggest Threat to Our Children & Future | 9-6-25
22.3K3 -
2:52:42
Mally_Mouse
1 day ago🔥🍺Spicy HYDRATE Saturday!🍺🔥-- Let's Play: Grounded
23.5K2 -
1:32:27
Patriots With Grit
5 hours ago"HELP... They're Killing Me" | Gail Seiler
7.26K1 -
3:07:51
Barry Cunningham
8 hours agoPRESIDENT TRUMP ANNOUNCES THE CHIPOCALYPSE! AND I'M HERE FOR IT! (AND MORE NEWS)
131K58 -
13:37
Exploring With Nug
11 hours ago $2.74 earnedTrying to Uncover Secrets in St Augustine’s Waters Missing Person Search!
25.6K3 -
24:09
MYLUNCHBREAK CHANNEL PAGE
1 day agoDams Destroyed The Ozarks
81.4K43