I have a question regarding syntax that I’ve been coming across in JavaScript.
What does it mean if I define functions or variables inside a context like the one just below?
(source: http://tutorialzine.com/2010/12/better-confirm-box-jquery-css3/)
(function($) {
$.confirm = function() {
...
}
$.confirm.hide = function() {
...
}
})(jQuery);
Also, what the $. mean in the function $.confirm? Also, with $.confirm.hide, I feel that there is some jQuery object involved.
By wrapping a function in parens then executed using to more parents
(function() {])();is a n immediately invoked function. By passing in jQuery within the 2nd set of parens you pass in a paramter which you are you passing in as$.$.confirmis just a method of thejQueryobjectMany libraries, like jQuery, use $ as a shortcut variable because it stands out from typical variables used in javascript.