title: Why is function() {...} needed to invoke a function after an onclick event?
body: <p>Why is it necessary to include <strong>function()</strong> here in JavaScript?</p>
  
  <pre><code>document.getElementById("mydiv").onclick = function() { myFunction(); };
  </code></pre>
  
  <p>Why does just putting the function you wish to invoke not work?</p>
  
  <pre><code>document.getElementById("mydiv").onclick = myFunction();
  </code></pre>