The key difference is that in the new object pattern, the window is creating the object by creating instances of the functions you're using to create the object. There are also ways to use just the new object pattern alone to accomplish the same things. The objects created like this inherit the methods by concatenation, which is good if you have a ton of prototypes or a ton of levels of inheritance. You can redefine an object's create method In order to create an instance of another object ( or many other objects in a chain) and return them to the object calling the create method. I personally have ditched the new object pattern entirely. I'm especially concerned with inherited methods on this one. This could cause a lot of unclear scopes and 'this' confusion. One half of your pattern addressees the window object to do its object creation, the other makes the object create itself. In this situation, I am most confused why you're mixing the object.create and the new object patterns. And you need to in order to unlock true prototypical inheritance. Making or discovering your own constructor patterns seems to me like part of the language learning process. It failed to attract the right programmers and now we're here. This was a lot in an effort to make JavaScript more Java like. Inheritly, they form objects that are what I would call psuedo prototypes- or prototypes with linear inheritance might be better. JavaScript constructor patterns are some of the least intuitive in programming.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |