Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passed in undefined argument in jQuery core source code

I noticed that in the jQuery core, one of the two arguments passed in is undefined.

(function( window, undefined ) {

    // Use the correct document accordingly with window argument (sandbox)
    var document = window.document;
    var jQuery = (function() {
        // ...defintion of the rest of the core...
    window.jQuery = window.$ = jQuery;
})(window);

Can anyone explain why the second argument is undefined?

Thanks in advance!

like image 550
maximus Avatar asked Mar 22 '11 17:03

maximus


People also ask

What does $() mean in jQuery?

In jQuery, the $ sign is just an alias to jQuery() , then an alias for a function. This page reports: Basic syntax is: $(selector).action() A dollar sign to define jQuery. A (selector) to "query (or find)" HTML elements.

What does $() short and stand for in jQuery?

$ is a short form of jQuery function. $() = jQuery() = window. $() = window. jQuery() $()/jQuery() is a selector function that selects DOM elements.

What is the jQuery function?

The jQuery library provides the jQuery function, which lets you select elements using CSS selectors.

Which built in method in jQuery?

on() is a built-in method in jQuery. It is used to assign one (or more than one) event handler to selected elements.


1 Answers

Undefined is a type but is also a global variable.

You can have a module that overwrites the value of undefined by doing undefined = whatever.

jQuery uses a immediate function to scope window and undefined.

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined

like image 57
masylum Avatar answered Oct 23 '22 07:10

masylum