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();
-
37:19
Athlete & Artist Show
22 hours ago $4.17 earnedZach Boychuk Says Farewell To Berlin, World Championships Experience, NHL Draft and MORE!
46K6 -
LIVE
TwinGatz
5 hours ago🔴LIVE - It's All So Tiresome | DOOM: The Dark Ages
226 watching -
8:14
The Art of Improvement
3 days ago10 Difficult Skills that Pay Off Forever
36.2K7 -
LIVE
STGKAMZZ
5 hours agoSUNDAY FUNDAY WIT KAMZ*WARZONE ACTION
103 watching -
1:11
Damon Imani
22 hours agoThe View Got TORCHED by Damon for COVERING UP Biden’s Decline!
35.1K21 -
LIVE
CassaiyanGaming
2 hours agoCall of Duty with FoeDubb| Saturday
81 watching -
LIVE
xBattledROid
2 hours ago $0.18 earned🔴LIVE - Testing my internet and playing some Marvel Rivals!
25 watching -
LIVE
STXReaper
5 hours agoWarzone resurg
80 watching -
LIVE
Astral Doge Plays!
7 hours agoOblivion Remastered ~LIVE!~ Blood of the Devines
78 watching -
1:41:23
xBuRnTx
6 hours agoLIVE - Day 18 of Creator Program
24K2