views:

44

answers:

1
var 
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
undefined,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$,

jQuery = window.jQuery = window.$ = function( selector, context ) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init( selector, context );
};

Why does jQuery need "_$ = window.$" or "_jQuery = window.jQuery"? It doesn't make sense to me, but without this two lines, the framework doesn't work.

Thanks for any help..

+3  A: 

It's saving a reference to the values of $ and jQuery before it overwrites them so that you can call jQuery.noConflict() and restore the values.

noah
ok, thanks for the quick response and sorry for this stupid questions. Now it's clear, that this is only a reference. I didn't see anything anymore in this big javascript jungle :D
Bernd Artmueller