Weird syntax for extending jQuery
<p>I recently saw this code on another post ( <a href="http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area">http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area</a> )</p>

<pre><code>new function($) {
    $.fn.setCursorPosition = function(pos) {
        // function body omitted, not relevant to question
    }
} (jQuery);
</code></pre>

<p>After too long trying to understand what it was doing I finally figured out that it's just creating a new function with a parameter $ and then invoking it with jQuery as the parameter value.  </p>

<p>So actually, it's just doing this:</p>

<pre><code>jQuery.fn.setCursorPosition = function(pos) {
    // function body omitted, not relevant to question
}
</code></pre>

<p>What's the reason for the original, more confusing version?</p>
