title: Variable loses value on if statement in javascript
body: <p>I have this simple HTML layout as a test page:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;
    &lt;/script&gt;
  
    &lt;script&gt;var user = 'test';&lt;/script&gt;
  
    &lt;script&gt;
    $(document).ready(function () {
         if(!user) {
            var user = '0';
         }
         alert(user);
    });
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>For some reason when checking the value of <code>!user</code> using the if condition, the condition is successful and the variable <code>user</code> gets the new value of <code>0</code> although I defined it previously. This has been driving me crazy for sometime now. Is there something wrong with the above code?</p>