DEV Community

The magical world of JavaScript prototypes

Belén on September 11, 2019

How many times have we heard "JavaScript is not an Object-Oriented language, it's Prototype-oriented"? It turns out it's not accurate. Here there ...
Collapse
 
mustapha profile image
Mustapha Aouas • Edited

For poeple that are wondering what's the difference, prototype is the object that is used to build __proto__ when you create an object with new.

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.

Collapse
 
lenaalcie_18 profile image
Lena Tevar

I'm studying js and I love it, it makes such more sense now.