javascript global variable definition inside a function
===

I am having a global variable 'a' and I am using this inside a function and assigning a value, and when I use this variable outside the function it gives me 'undefined'.
Eg.:

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