title: Does a browser truly read JavaScript line by line OR does it make multiple passes?
body: <p>I understand that JavaScript is interpreted and not compiled.  No problem there.  However, I keep reading here that JavaScript is executed "on the fly" and that lines are read one at a time.  This idea is confusing me quite a bit when it comes to the following example:</p>
  
  <pre><code>writeToConsole();
  
  function writeToConsole() {
      console.log("This line was reached.");
  }
  </code></pre>
  
  <p>For the record, this bit of code will write to the console just fine.  Still, how would the browser know of the existence of <code>exampleFunction()</code> if it had not yet reached the function?</p>
  
  <p>In other words, <em>when</em> exactly is this function first interpreted?</p>