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.
This is part of a series where we go over Javascript in depth to learn programming concepts as well as web development: • Javascript In Depth
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
📦 Github Repository with the notes and exercise code+solutions: https://github.com/Nooder/javascript-...
💬 Come join us on Discord to chat with a like-minded community about tech and learning: / discord
🏅Support the channel and content through Super Thanks, Channel Memberships, or on Patreon: / techwithnader
In questa pagina del sito puoi guardare il video online Inheritance and Polymorphism - Classes and Object Oriented Programming (OOP) - Javascript In Depth della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Tech with Nader 26 December 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 3,778 volte e gli è piaciuto 195 spettatori. Buona visione!