Skip to content Skip to sidebar Skip to footer

What Is The Functional Difference Between These Two Different Module Pattern Syntaxes

I see this syntax everywhere: var mod = (function(){ var pvtvar; var pvtfunc = function(){}; //return an object literal return { pubvar : 'whatever', pubfunc : fun

Solution 1:

You're right. In your example, the first syntax is cleaner and more readable.

You use the second syntax when you want to pass along something more than an empty object into the module and get an augmented object in return.


Post a Comment for "What Is The Functional Difference Between These Two Different Module Pattern Syntaxes"