Web Dev Roadmap for Beginners (Free!): https://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 https://bit.ly/3nGHmNn
JavaScript for Beginners: Full Course (8 hours): https://youtu.be/EfAl9bwzVZk
Advanced Javascript Tutorials mentioned in this video:
Javascript Classes Tutorial: https://youtu.be/5fmifZZeJJ4
Javascript Prototypes Tutorial: https://youtu.be/mQ4oCgcgHOA
Pure FunctionsTutorial: https://youtu.be/ZXxahQS1PN8
Shallow Copy vs Deep Copy Tutorial: https://youtu.be/4Ej0LwjCDZQ
Decorator Functions Tutorial: https://youtu.be/wYs3rv_KFvk
Currying Functions Tutorial: https://youtu.be/I4MebkHvj8g
Source Code: https://gist.github.com/gitdagray/e3452b267fffb05ee25f0166ab15511f
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: https://twitter.com/yesdavidgray
LinkedIn: https://www.linkedin.com/in/davidagray/
Blog: https://yesdavidgray.com
Reddit: https://www.reddit.com/user/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