title: Immediate function invocation syntax
body: <p>There is a <a href="http://www.jslint.com" rel="noreferrer">JSLint</a> option, one of The Good Parts in fact, that "[requires] parens around immediate invocations," meaning that the construction</p>
  
  <pre><code>(function () {
  
    // ...
  
  })();
  </code></pre>
  
  <p>would instead need to be written as</p>
  
  <pre><code>(function () {
  
    // ...
  
  }());
  </code></pre>
  
  <p>My question is this -- can anyone explain why this second form might be considered better?  Is it more resilient?  Less error-prone?  What advantage does it have over the first form?</p>
  
  <hr>
  
  <p>Since asking this question, I have come to understand the importance of having a clear visual distinction between function values and the values of functions.  Consider the case where the result of immediate invocation is the right-hand side of an assignment expression:</p>
  
  <pre><code>var someVar = (function () {
  
    // ...
  
  }());
  </code></pre>
  
  <p>Though the outermost parentheses are syntactically unnecessary, the opening parenthesis gives an up-front indication that the value being assigned is <em>not</em> the function itself but rather the result of the function being invoked.</p>
  
  <p>This is similar to Crockford's advice regarding capitalization of constructor functions -- it is meant to serve as a visual cue to anyone looking at the source code.</p>