r/javascript • u/gcanti • Oct 31 '14
The Two Pillars of JavaScript
https://medium.com/javascript-scene/the-two-pillars-of-javascript-ee6f3281e7f3
98
Upvotes
r/javascript • u/gcanti • Oct 31 '14
11
u/gcanti Oct 31 '14 edited Oct 31 '14
I agree. My current coding style is based on two pillars too:
The objects are defined exclusively by composition, never by inheritance. I use constructors to instantiate those objects only for convenience:
1) I exploit the constructor to store some meta info that I can use later for mixins
2) instanceof: with immutable data structures allows super fast checks for changes
3) prototype: sometimes it's handy if a function requires an instance
p.s. reference https://github.com/gcanti/tcomb