Hi all, I come here with quite a bunch of questions so lets start:
I want to know some things about the syntax used to make jquery as I wish to learn from it an use it for my self.
Question 1:
The starting of the jQuery library
(function( window, undefined ) {
// Define a local copy of jQuery
var jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context );
},
// Map over jQuery in case of overwrite
_jQuery = window.jQuery, .......
I would like to know what is meant by the bracket before the function like so "(function(window..." until now I have only declared my function like this
function myFunc(myArg1,myArg2){
//stuff
}
Question 2:
At the end of the jquery library I seem to understand that the $ sign is assigned in the global scope so that we can use the $ anywhere for the selectors, what i dont understand is that what does the "(window);" expression at the very end mean, and what purpose does it serve.
};
});
// Expose jQuery to the global object
window.jQuery = window.$ = jQuery;
})(window);
My final question is, how can I go about making a globally accessable javascript Object of my own that I can use with lets say "ds.functionName(Arg1);" just like JQuery is used with the $ sign
Thank you :D