title: Why can't I use a Javascript function before its definition inside a try block?
body: <p>As discussed <a href="https://stackoverflow.com/questions/261599/why-can-i-use-a-function-before-its-defined-in-javascript">here</a>, function definitions can be used before they're defined. But as soon as a section of code is wrapped in a try block, this ceases to be the case.</p>
  
  <p>This displays "Hello world":</p>
  
  <pre><code>hello();
  function hello() { alert("Hello world"); }
  </code></pre>
  
  <p>But this displays "ReferenceError: hello is not defined":</p>
  
  <pre><code>try {
    hello();
    function hello() { alert("Hello world"); }
  } catch (err) {
    alert(err);
  }
  </code></pre>
  
  <p>So there is clearly something "special" about a try block with respect to function declarations. Is there any way to get around this behavior?</p>