title: I don't understand the significance of the following javascript code:
body: <p>I don't understand the significance of the following javascript code:</p>
  
  <pre><code>var func = f()
      func() 
  </code></pre>
  
  <p>Can anyone afford to explain it to me? as surely,I am not an expert in javascript.
  The complete code that I found on net is given:</p>
  
  <pre><code>    var a = 1
  function f() {
  
    function g() {
      alert(a)
    }
  
    return g 
  }
  
  var func = f()
  func() // 1
  </code></pre>
  
  <p>It was trying to illustrate closure,lexicalenvironment. any help is appreciated. I found it on <a href="http://javascript.info/tutorial/closures" rel="nofollow">http://javascript.info/tutorial/closures</a></p>