Why does jQuery use the comma operator for variable assignment so much?
<p>Here’s an excerpt from the start the jQuery source code (1.7.1):</p>

<pre><code>// Define a local copy of jQuery
var jQuery = function( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced'
        return new jQuery.fn.init( selector, context, rootjQuery );
    },

    // Map over jQuery in case of overwrite
    _jQuery = window.jQuery,

    // Map over the $ in case of overwrite
    _$ = window.$,


    // ...continues...


    // [[Class]] -&gt; type pairs
    class2type = {};
</code></pre>

<p>The code is a series of variable assignments, all joined by the comma operator. As I understand <a href="https://developer.mozilla.org/en/JavaScript/Reference/Operators/Comma_Operator" rel="nofollow">the comma operator</a>, it evaluates the expressions before and after it, and returns the value of the latter one.</p>

<p>As the chain of variable assignments isn’t being assigned to anything, it struck me that the code could be rewritten with semicolons in place of the commas, without changing how it operates. E.g.</p>

<pre><code>// Define a local copy of jQuery
var jQuery = function( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced'
        return new jQuery.fn.init( selector, context, rootjQuery );
    }; /* &lt;----- semicolon */

    // Map over jQuery in case of overwrite
    _jQuery = window.jQuery; /* &lt;----- semicolon */

    // Map over the $ in case of overwrite
    _$ = window.$; /* &lt;----- semicolon */

    // ...and so on.
</code></pre>

<ol>
<li><p>Would the code have the same effect if rewritten with semicolons like this, or am I missing something?</p></li>
<li><p>If it <em>would</em> have the same effect, what are the style reasons for writing it with commas? (I know, for example, that <a href="http://javascript.crockford.com/code.html" rel="nofollow">Crockford doesn’t like the comma operator (see near the bottom)</a>, although I don’t know why.)</p></li>
</ol>
