![]() ![]() ![]() The prototype property is available if people want to inherit. Now, Doug has been coding software for a long time, therefore it makes sense to listen to what he has to say. ![]() The Good Parts is really a story of how enlightenment came to be on Mr. No other book has had quite the impact on the JavaScript ecosystem as Douglas Crockford’s The Good Parts. When they want one, they call Xyz.create(), and get back a new, initialized object of my type. Douglas Crockford The Good Parts Examples. the create() function is for users of my type. I return an object with a create() function, and a prototype property. This means I have a private space to work without making a mess in the global namespace. You can find his object creation function here: if (typeof Object.create != 'function') )(). ![]() However, JS is as it is so go and use "new". He (IMHO rightly) says that the way it turned out JS is conflicted, prototype based but with this one thing from "classical class" inheritance languages. I understand this particular statement to be more on an "academic" level, what SHOULD have been HAD the language been designed "right" and not with some leftovers of the class-based inheritance stuff. However, the YUI(3) team itself uses "new", and they DO follow his recommendations (since he's the Yahoo chief JS architect (UPDATE: he moved on, but the statement was true when this response was originally written). Crockford gives an example for an object creation function as should have been provided by JS itself in one of his Javascript talks available on ![]()
0 Comments
Leave a Reply. |