jQueryand $actually the same.
If you pass a function to a function $(), jQuery basically checks its type, and if it is a function, it will execute when the DOM is ready. This is just Javascript:
function myFunc(arg){
if(typeof arg == 'function'){
arg.call();
}
}
From jQuery source:
_jQuery = window.jQuery,
_$ = window.$,
...
window.jQuery = window.$ = jQuery
...
noConflict: function( deep ) {
window.$ = _$;
if ( deep ) {
window.jQuery = _jQuery;
}
return jQuery;
}
If you call the jQuery function, it checks the type of the argument:
init: function( selector, context ) {
...
else if ( jQuery.isFunction( selector ) ) {
return rootjQuery.ready( selector );
}
Where rootjQuerycoincides withjQuery(document)
source
share