xxxxxxxxxx
(function(){
// all your code here
alert("XXXXXX");
})();
/*this field executes immediates when it created*/
xxxxxxxxxx
(function () {
console.log("first");
$ = function (){
console.log("second");
}
})()
/*without the $= part in the other example, $() can be invoked outside the function*/