title: Javascript Closure not providing expected result
body: <p>I am trying to understand closures. </p>
  
  <pre><code>var a = 1;
  
  var g = function () {
    var a = a;
    return function() {
      console.log(a);
    }
  }
  
  g()();
  </code></pre>
  
  <p>As far as I know, the function invocation <code>g()()</code> should log the value of a, i.e. 1. But it is logging <code>undefined</code> on the console. I know my concept is weak somewhere, but am not able to figure out even after spending few hours. Can someone help?</p>