title: ReferenceError: variable is not defined
body: <p>I met this issue sometimes but still don't know what causes it.</p>
  
  <p>I have this script in the page:</p>
  
  <pre><code>$(function(){
      var value = "10";
  });
  </code></pre>
  
  <p>But the browser says "ReferenceError: value is not defined". However if I go to the browser console and input either</p>
  
  <pre><code>10
  </code></pre>
  
  <p>or</p>
  
  <pre><code>var value = "10";
  </code></pre>
  
  <p>either of them can return 10. What is the problem with my script?</p>