4 ms·
The JavaScript prototype pattern is the most poorly designed aspect of the JavaScript language. Cross-browser prototype compatibility is a total headache too.
by fasteddie31003 14y ago
The JavaScript prototype pattern is the most poorly designed aspect of the JavaScript language. Cross-browser prototype compatibility is a total headache too.
My solution: abstract away the headache. Use Underscore's extends function or take a look at how Prototype.js handles inheritance: http://prototypejs.org/learn/class-inheritance http://prototypejs.org/learn/class-inheritance .
Both solutions are much more simple and do the same thing.
Also, if you are going into a JavaScript interview, know the stupid prototype pattern, someone always asks about it.
- ryankinal 14y agoI disagree. I think the prototype pattern is quite well designed. It's just not well-supported across browsers. The Pseudo-Classical/Constructor pattern is the one that's broken.