Рет қаралды 14,032
Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
Why you should choose composition over inheritance when you are creating objects. This tutorial will look at both approaches to creating objects and show you why composition is the best choice as well as the problems that arise with inheritance.
🚩 Subscribe ➜ bit.ly/3nGHmNn
🚀 JavaScript for Beginners: Full Course (8 hours): • JavaScript Full Course...
Advanced Javascript Tutorials mentioned in this video:
🔗 Javascript Classes Tutorial: • Javascript Classes Exp...
🔗 Javascript Prototypes Tutorial: • What is __proto__ ? | ...
🔗 Pure FunctionsTutorial: • What are Pure Function...
🔗 Shallow Copy vs Deep Copy Tutorial: • Shallow Copy and Deep ...
🔗 Decorator Functions Tutorial: • Video
🔗 Currying Functions Tutorial: • How to Curry Functions...
🔗 Source Code: gist.github.com/gitdagray/e34...
Why you should choose composition over inheritance | Javascript OOP Tutorial
(00:00) Intro
(0:18) Problems with object inheritance
(4:45) Composition to the rescue
(10:41) Data structure mutation
(12:51) Cloning to avoid mutation
(16:15) Bonus: Refactoring to a declarative expression
(17:49) Review of Composition
✅ Follow Me:
Twitter: / yesdavidgray
LinkedIn: / davidagray
Blog: yesdavidgray.com
Reddit: / daveoneleven
Was this tutorial about choosing Javascript object composition over inheritance helpful? If so, please share. Let me know your thoughts in the comments.
#composition #inheritance #javascript