Difference Between Javascript Wrapping Methods
<p>It is generally accepted that Javascript code should be wrapped in a function to prevent leaking to the global scope and just assign whatever you need outside of each function to the <code>head</code> object (<code>window</code> in web browsers).</p>

<p>I've seen two primary methods of this in the wild:</p>

<p><strong>Method 1:</strong></p>

<pre><code>(function() {
  // code here
}).call(this);
</code></pre>

<p><strong>Method 2:</strong></p>

<pre><code>(function() {
  // code here
})();
</code></pre>

<p><strong>Method 1</strong> is from compiled CoffeeScript code, and <strong>Method 2</strong> seems to be the preferred style for jQuery plugins:</p>

<p>Modified Method 2 for jQuery:</p>

<pre><code>(function($) {
  // JQuery Code
})(jQuery);
</code></pre>

<p><strong>Question:</strong> What is the difference between <strong>Method 1</strong> and <strong>Method 2</strong>? CoffeeScript likes to focus on conciseness, so I figure there must have been a reason for the people behind CoffeeScript to choose <strong>Method 2</strong> over <strong>Method 1</strong>.</p>
