DEV Community

Discussion on: The magical world of JavaScript prototypes

Collapse
 
73nko profile image
73NKo

Great article! I love the new horchata spell!

I have a question that maybe its not very related the article but I think so. Some people thinks despite javascript has this inheritance through proptotype chain is better use composition with a factory function. What do you think about that? I use to have discussions gorila-banana problem vs better performance. What would be in your opinion a better approach?

Collapse
 
ladybenko profile image
Belén

Thanks!

I'm more keen to use composition over inheritance unless I really need a different type (and in this case, I try not to have a chain, but just a single subtype), but I'm afraid prototypes have nothing to do with this. Composition vs Inheritance is a debate that extends to every Object-Oriented language, independently if they have prototypes or not.