title: When should I put a semicolon after a function in javascript?
body: <p>My examples:</p>
  
  <p>(First example <strong>area</strong> is the function assignment with semicolon)</p>
  
  <pre><code>function makeImage() {
  var canvas = document.getElementById("tshirtCanvas");
  **canvas.onclick = function () {
      window.location = canvas.toDataURL('image/png');
  };**
  }
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>window.onload = function() {
      var button = document.getElementById("previewButton");
      button.onclick = previewHandler;
  
  
      makeImage();
  }
  </code></pre>
  
  <p>I thought I had the hang of when to use it, and when not to, but I guess I do not. Thanks.</p>