1

I've been looking at the jquery source code. It first declares a bunch of variables like this:

var deletedIds = [];
var slice = deletedIds.slice;
var concat = deletedIds.concat;

then it start declaring a comma separated list of functions and variables:

var
    version = "1.11.2",

    // Define a local copy of jQuery
    jQuery = function( selector, context ) {
        // The jQuery object is actually just the init constructor 'enhanced'
        // Need init if jQuery is called (just allow error to be thrown if not included)
        return new jQuery.fn.init( selector, context );
    },

My question is why doesn't it declare all of them as a comma separated list? Or why use the comma separated list method, why not just declare all the functions and variable like the first 3?

jfriend00
  • 683,504
  • 96
  • 985
  • 979
behnam
  • 159
  • 1
  • 1
  • 7
  • 1
    Both methods are acceptable and correct. The answer of question can give only that person who have written this code. – Manwal Mar 04 '15 at 09:25
  • 1
    jQuery is not build by writing all the code into one file by hand. They use a build system, to _concat_ all the files into the final `jquery.js` file. Those build system do some variable declaration on their own. If you want to see how jQuery is actually structured you need to look at the source on [github](https://github.com/jquery/jquery/tree/master/src). – t.niese Mar 04 '15 at 09:34

0 Answers0