7 ms·
"Also, since JavaScript has no formal classes there is no self-evident approach for structuring an entire application." Really? http://javascript.crockford.com
by ryandotsmith 16y ago
"Also, since JavaScript has no formal classes there is no self-evident approach for structuring an entire application."
Really? http://javascript.crockford.com/prototypal.html http://javascript.crockford.com/prototypal.html
- natevw 16y agoCare to explain what you mean? Given that... - Crockford originally thought it worthwhile to emulate classical inheritance - so many, many other frameworks (and technique essays) provide various flavors of class-based inheritance and that: - even embracing true prototypical inheritance requires additional helper functions (or at least did in EcmaScript 3) ...I'm a little confused that you disagree that "there is no self-evident approach" for dealing with JavaScript's 'conflicted' (as the linked article correctly states) way of being a so-called prototypical language.
- jashkenas 16y agoPlease don't just quote Crockford as gospel truth. Crockford's prototypal revelation is only a slight alteration of the standard constructor pattern, and not a particularly useful one. You still have a class (the object that serves as a prototype for every instance you create), it doesn't add any particular flexibility, and it's quite slow. I encourage you to run the tests yourself: http://jsperf.com/object-create-vs-crockford-vs-jorge-vs-constructor/9 http://jsperf.com/object-create-vs-crockford-vs-jorge-vs-con... For me, that test clocks using Crockford's pattern to instantiate objects as 80% slower in Safari and Firefox, and 95% slower in Chrome, when compared to a standard use of JS prototypes.