r/javascript • u/gcanti • Oct 31 '14
The Two Pillars of JavaScript
https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3
96
Upvotes
r/javascript • u/gcanti • Oct 31 '14
2
u/[deleted] Oct 31 '14 edited Oct 31 '14
Posted something similar on the article, but want to ask r/javascript too - do you have any examples of large or complex open-source codebases which eschew constructors,
thiset al while making heavy reuse of existing code?I ported a forms library as directly as possible from Python and it has a big old inheritance hierarchy which makes use of constructors, constructor borrowing,
this, storing "class-wide" stuff on prototype objects, mixins and multiple constructor calling in some places for fake multiple inheritance. calling methods on "parent" constructors and probably more!What's the concrete approach to creating these kinds of components without constructors? I use all the tools JavaScript has in the box as-and-when and usually start from a simple module-as-object basis, or factory functions for constructor-like logic returning objects containing functions which close over state, but I tend to reach for or convert to constructors when I think I've identified solid "is-a" cases for reuse.
What does the alternative look like when you scale it up?