If you're a senior developer or architect, I bet you know the most popular concepts, design patterns, and how stuff works inside. But still, not many front-end devs go think so much about composition and inheritance. It's not an often discussed topic, and I've noticed not all devs can explain why they created their solution with this or this way. In today's article, we'll talk about two programming concepts, composition and inheritance. I will tell you what composition is and what inheritance is, but not only. You'll learn about how they look in js as well in react.js. Next, we'll compare them together and look at which one is better to use, when to use composition and when it is better to go with inheritance. Because it's an article related to composition vs inheritance targeted to React, I will not go very deep in programming concepts as inheritance or composition in general. I will just explain them shortly, and I'll focus on the topic - the comparison.













