Why does jquery need _ $ in case of rewriting?

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 "_QQuery = window.jQuery"? For me this does not make sense, but without these two lines the structure does not work.

Thanks for any help ..

+3
source share
1 answer

Keeps a reference to the $ and jQuery values ​​before overwriting them so you can call jQuery.noConflict()and restore the values.

+4
source

Source: https://habr.com/ru/post/1735437/


All Articles