title: Difference in setting a function as anonymous
body: <p>I know there is a great difference in 2 methods below:</p>
  
  <pre><code>a.onclick = function() {alert("Hi");};
  </code></pre>
  
  <p>and</p>
  
  <pre><code>a.onclick = (function() {alert("Hi");};)();
  </code></pre>
  
  <p>Why do people use the second method? The second should fire the alert() on page load but doesn't?</p>
  
  <p>Why in <a href="https://stackoverflow.com/questions/6895564/difference-between-onbeforeunload-and-onunload">Difference between onbeforeunload and onunload</a> does the first guy uses the anonymous and the second uses the right one?</p>