javascript function with in function in variable <p>I have a doubt </p> <p><strong>My Code :-</strong></p> <pre><code>function f() { var g = function() { return 1; } return g; }; </code></pre> <p>How do I can call g? I want to return 1 once and again I want to return g.</p> <p>I did a Research I found a solution </p> <p>How we can call g is:- </p> <pre><code>f()(); </code></pre> <p>Why this is ?? What is <code>f()();</code> in JavaScript. why not we can achieve this using <code>f.g</code> or something.</p> <p>How can I return g from the function f ??</p> <p>Please clarify my doubts ?</p>