Javascript closure
<p>The following program returns "local" and, according to the tutorial I<code>m reading, it is designed to demonstrate the phenomenon of</code>closure`</p>

<p>What I don`t understand is why, at the end, in order to call parentfunction, it assigns it to the variable "child" and then calls "child."</p>

<p>Why doesn`t it work by just writing parentFunction();  at the end?</p>

<pre><code>var variable = "top-level";
function parentFunction() {
  var variable = "local";
  function childFunction() {
    print(variable);
  }
  return childFunction;
}

var child = parentFunction();
child();
</code></pre>
