title: Defining JavaScript variables inside if-statements
body: <p>Is defining JavaScript variables inside if-statements correct?</p>
  
  <pre><code>if(a==1){
      var b = 1;
  } else {
      var b = 0;
  }
  </code></pre>
  
  <p>I know the code above will work, however, WebMatrix highlights the variables.</p>
  
  <p>Should I define the variables outside the if-statement? Or the first option's correct? Or it doesn't really matter?</p>
  
  <pre><code>var b = '';
  if(a==1){
      b = 1;
  } else {
      b = 0;
  }
  </code></pre>