JavaScript global variable definition inside a function
<p>I have a global variable <code>a</code> and I am using it inside a function and assigning a value to it. When I use this variable outside the function it gives me <code>undefined</code>.</p>

<p>Eg.:</p>

<pre><code>var a;
function my_func(){
  a=5;
}
console.log(a); //outputs undefined, how do I get the value 5 here
</code></pre>

<p>Why do I get <code>undefined</code> instead of <code>5</code>?</p>
