title: Understanding jquery source code
body: <p>I have recently started to delve deeper in to JavaScript and have come across this code construct in JQuery.</p>
  
  <pre><code>(function( window, undefined ) {
  })(window)
  </code></pre>
  
  <p>Reading on stack overflow (and elsewhere) I have come to the conclusion that this is the same as</p>
  
  <pre><code>function foo(window, undefined) {
      ...
  }
  
  foo(window);
  </code></pre>
  
  <p>Am I correct in my assumption?
  If so, what are the advantages of the former? (other than confusing newbs)</p>