title: self-defining function(also called lazy function definition) when using function declaration
body: <p>In the "JavaScript Patterns" book by Stoyan Stefanov, there's a part about Self-Defining Function.</p>
  
  <pre><code>var scareMe = function(){
      console.log("Boo!");
      scareMe = function(){
          console.log("Double Boo!"); 
      }
  }
  
  scareMe();//==&gt;Boo!
  scareMe();//==&gt;Double Boo!
  </code></pre>
  
  <p>It works as I expected. But I modify the scareMe function as following:</p>
  
  <pre><code>function scareMe(){
       console.log("Boo!");
       function scareMe(){
           console.log("Double Boo!");
       }
   }
  
   scareMe();//==&gt;Boo!
   scareMe();//==&gt;Boo!
  </code></pre>
  
  <p><strong>Problem</strong>: </p>
  
  <ol>
  <li>what's the difference between them?</li>
  <li>In the second case, why the output is not "Double Boo!", but "Boo!" </li>
  </ol>