title: JavaScript function x(){..} treated as var x=function(){..} inside `if' in Firefox, not in Chrome and Opera
body: <p>Consider the following JavaScript code:</p>
  
  <pre><code>(function(){
    foo();
    function foo(){ alert('Hello, World!'); }
  })();
  </code></pre>
  
  <p>In Firefox, Opera and Chrome, this behaves as expected; we get an alert. Now in contrast:</p>
  
  <pre><code>(function(){
    if (true){
      foo();
      function foo(){ alert('Hello, World!'); }
    }
  })();
  </code></pre>
  
  <p>Firefox 3.6 and 4 (beta) (i.e. SpiderMonkey for both) throws an exception: foo is not defined</p>
  
  <p>Chrome (i.e. V8) and Opera (i.e. whatever engine Opera uses) work as expected (by me).</p>
  
  <p>Which is the correct behaviour, or is this left to implementations to decide?</p>
  
  <p>FWIW, wrap it up in a function again and it's good to go in FF again:</p>
  
  <pre><code>(function(){
    if (true){
      (function(){
        foo();
        function foo(){ alert('Hello, World!'); }
      })();
    }
  })();
  </code></pre>