(function(){ ... })();
I HAVE looked at this post and understood a bit about it. But there are few more doubts, mostly on how it is used.
Like a Static block!
since it acts like a static block (self invoking!), it can be used for initializing(like some make-believe constants)?
But then there is no getter
available to fetch anything from it and use it elsewhere!
return, Must?
The solution to above is to HAVE a return
in that function? so that I can fetch whatever it returns and use that.
reference to the global object?!
(function(window, undefined){})(this);
The explanation for the above code was in the second answer of the referenced post, I couldn't understand it, If anyone can explain it more (or simpler for me), It will be great
update: Take a look at this code ↓
var myElement=document.getElemetById("myElementId");
(function(myElement){
/**'this' here is 'myelement'???**/
};
})(this);