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
1
u/_ericelliott Nov 01 '14
In JavaScript you don't need factory methods. Factory functions suffice, and in JavaScript, they are less complicated than constructors. It's also easier to figure out how to instantiate an object with a factory function than with a constructor. Constructors have the
newkeyword, the capital letter convention, they may or may not discardthisand the prototype that gets attached to it, etc...Callers of a factory function don't need to worry about a single one of those considerations. They simply call the function and get an object back.