title: What is the functional difference between these two different Module pattern syntaxes
body: <p>I see this syntax everywhere:</p>
  
  <pre><code>var mod = (function(){
    var pvtvar;
    var pvtfunc = function(){};
  
    //return an object literal
    return {
      pubvar : 'whatever',
      pubfunc : function(){}
    };
  }());
  </code></pre>
  
  <p>I recently came across this syntax:</p>
  
  <pre><code>//first create empty object
  var mod = {};
  (function(mod){
    var pvtvar;
    var pvtfunc = function(){};
  
    //modify the mod object argument
    mod.pubvar = 'whatever';
    mod.pubfunc = function(){};
  }(mod)); //pass object to IIFE
  </code></pre>
  
  <p>I know that they both work, and I <em>think</em> I understand completely why, I just want to make sure I'm not missing anything...Given identical members you end up with identical objects, it's just that in the second example <code>mod</code> references an empty object within the global scope for a fraction of a second, while in the first example <code>mod</code> only ever references the complete object once its value is returned by the IIFE. </p>
  
  <p>So, am I correct in thinking that the <strong>only</strong> difference is the (very small) amount of time that the second object lives as an empty object?
  And, my follow up question: do you use the second syntax, and why?</p>