title: When to use var in Javascript
body: <p>Maybe pretty easy question. </p>
  
  <p>Where should I use <code>var</code> keyword in JavaScript. It seems to me using it or not have the same effect ( but of course I'm still learning the language ) </p>
  
  <p>For instance these both seems the same to me:</p>
  
  <pre><code>(function(){
    var a = "mundo"
    alert("Hola, " + a )
  })()
  </code></pre>
  
  <p>and </p>
  
  <pre><code>(function(){
    a = "mundo"
    alert("Hola, " + a )
  })()
  </code></pre>
  
  <p>But of course there must be a more complex example where the difference shows up.</p>