title: Variable scope problem
body: <p>Since I am a JavaScript newbie, I started learning it but I got stuck just at the beginning.
  I am following <a href="https://developer.mozilla.org/en/JavaScript/Guide/Values,_Variables,_and_Literals#Variable_Scope" rel="nofollow">a Mozilla Tutorial</a> and I have a problem with variable scope in JavaScript. I have some code:</p>
  
  <pre><code>var myvar = "my value";
  
  var zmienna = "string";
  
  (function () {
      alert(myvar);
      alert(zmienna);
  })();
  
  (function () {
      alert(myvar); // undefined
      var myvar = "local value";
      alert(zmienna);
  })();
  </code></pre>
  
  <p>In the tutorial, I've read that JavaScript variables are not visible from function blocks. Well, first two alerts says correct values. It's strange then, because third alert says "undefined", despite fact that nothing has changed from previous function block. The fourth one, again, prints right value.</p>
  
  <p>Could anybody explain me, what is happening here? I would be very glad, because tutorial says nothing more about that.</p>