T
T
thehighhomie2016-03-09 12:40:55
JavaScript
thehighhomie, 2016-03-09 12:40:55

JavaScript OOP, confused?

I read the book "JavaScript for Professionals: 2nd edition" and got completely confused. This book has presented a single pattern for creating code reuse, that is, OOP. here is an example of this template https://jsfiddle.net/7zn5ccgq/ The author wrote that the prototype property does not need to be climbed at all. As far as I know, when I started learning JavaScript, in all the documentation I read, including on learn.javascript.ru, they describe what is usually preferable to OOP in a prototypal style. But in what style as I usually write codepen.io/radum/pen/xICAB(this is not my code, just an example) And here is the author who created jQuery. Either while I was learning JavaScript, something changed in this regard, but I taught it so that I didn’t notice, or the creator of jquery went crazy, or I don’t understand anything at all ... Help please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-03-09
@thehighhomie

code reuse creation pattern i.e. oop

You are confused. OOP is not about code reuse, functions/procedures are more responsible for it. Objects are responsible for hiding the state.
From inside the object instance - yes. When you describe a new type of objects and want to follow up, you need to specify the prototype of the object.
Slightly changed, ES2015 was released, last year. Now everything is a little simpler and working with object prototypes when inheriting/defining new objects has become a little more transparent and convenient. And you can remember about createObject/defineProperties just to understand how everything works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question