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();
-
1:30:46
Glenn Greenwald
16 hours agoBeirut Bombing: Is There Any Limit On Civilian Deaths? Interview With Harvard Grad Alleging Campus Antisemitism | SYSTEM UPDATE #343
118K207 -
4:51:46
Nerdrotic
18 hours ago $58.47 earnedRings of Power HATES Tolkien, Agatha FLOPS, The Penguin ROCKS - Friday Night Tights #321 YellowFlash
174K80 -
1:29:19
Roseanne Barr
14 hours ago $35.55 earnedNicole Shanahan Is BASED AF | The Roseanne Barr Podcast #67
107K126 -
3:12:47
I_Came_With_Fire_Podcast
14 hours agoLive Fire (No Exercise)
72.1K12 -
1:31:58
Flyover Conservatives
1 day agoTrump Train Triumphs over Biden-Harris Lawfare! - Joeylynn Mesaros; Weak Men and the Threat to Our Nation’s Security - Chris Rodack | FOC Show
72.9K15 -
1:26:59
Hathor Studios
1 day agoCode 12 — The Movie
91.8K39 -
1:15:59
JoBlo Originals
13 hours agoFriday Night Flicks!
60.6K -
4:30:52
Tundra Gaming Live
16 hours agoThe Worlds Worst Horror Streamer Has Heart Attack Playing Phasmophobia
50.6K4 -
1:07:00
Havoc
17 hours agoFeds on a Rampage | Stuck Off the Realness Ep. 15
49.1K8 -
1:06:37
Edge of Wonder
15 hours agoPanda Cloning, Do You Trust Chinese AI? & Jungle Walrus Cryptid
46.2K5