I was reading some posts about closures and saw this everywhere, but there is no clear explanation how it works - everytime I was just told to use it...:
//
When you did:
(function (msg){alert(msg)}); ('SO');
You ended the function before ('SO') because of the semicolon. If you just write:
('SO')
(function (msg){alert(msg)}) ('SO');
It will work.
Working example: http://jsfiddle.net/oliverni/dbVjg/