filmov
tv
Inheritance and Polymorphism - Classes and Object Oriented Programming (OOP) - Javascript In Depth

Показать описание
We learn about two of the four pillars of OOP: Inheritance and Polymorphism. We take a look at how these work specifically in Javascript together.
To start, we look back at why we need more than just Classes and how we can avoid duplicate code by creating a template and defining a "super" and "sub" class.
We take a detailed look at the "super" keyword and how it works to call the constructor in the parent class but also methods from the parent's prototype/class.
We wrap up by taking a look at Polymorphism and the power it has when combined with Inheritance. This also leads us to learning about the "instanceof" operator in Javascript.
Note that this is an advanced topic and will take a lot of practice and trying different things over time to really cement. We'll go through some practice exercises together on Inheritance and Polymorphism in the next video in the series.
Chapters:
00:00 Introduction
01:05 4 Pillars of OOP Recap
01:50 Fantasy Game Player and Enemy
03:00 A Warrior Class
04:18 Warrior and Wizard Classes
07:20 Warrior, Wizard and Bartender Classes
09:40 A Base Player Class (Super Class)
12:41 The Warrior Sub-Class
20:57 Super and Sub-Class Code Example
33:38 Inheriting Methods
35:35 Inheriting Methods Code Example
38:32 The "super" keyword
40:40 "super" keyword Code Example
45:53 "instanceof" keyword
50:29 Polymorphism
58:20 Polymorphism Code Example
1:05:09 Next Steps
To start, we look back at why we need more than just Classes and how we can avoid duplicate code by creating a template and defining a "super" and "sub" class.
We take a detailed look at the "super" keyword and how it works to call the constructor in the parent class but also methods from the parent's prototype/class.
We wrap up by taking a look at Polymorphism and the power it has when combined with Inheritance. This also leads us to learning about the "instanceof" operator in Javascript.
Note that this is an advanced topic and will take a lot of practice and trying different things over time to really cement. We'll go through some practice exercises together on Inheritance and Polymorphism in the next video in the series.
Chapters:
00:00 Introduction
01:05 4 Pillars of OOP Recap
01:50 Fantasy Game Player and Enemy
03:00 A Warrior Class
04:18 Warrior and Wizard Classes
07:20 Warrior, Wizard and Bartender Classes
09:40 A Base Player Class (Super Class)
12:41 The Warrior Sub-Class
20:57 Super and Sub-Class Code Example
33:38 Inheriting Methods
35:35 Inheriting Methods Code Example
38:32 The "super" keyword
40:40 "super" keyword Code Example
45:53 "instanceof" keyword
50:29 Polymorphism
58:20 Polymorphism Code Example
1:05:09 Next Steps
Комментарии