title: JavaScript scope in a try block
body: <p>Say I'm trying to execute this JavaScript snippet. Assume the undeclared vars and methods are declared elsewhere, above, and that <code>something</code> and <code>somethingElse</code> evaluate to boolean-true.</p>
  
  <pre><code>try {
      if(something) {
          var magicVar = -1;
      }
  
      if(somethingElse) {
          magicFunction(magicVar);
      }
  } catch(e) {
      doSomethingWithError(e);
  }
  </code></pre>
  
  <p>My question is: what is the scope of <code>magicVar</code> and is it okay to pass it into <code>magicFunction</code> as I've done?</p>