title: javascript function internal scope
body: <p>Consider the following code:</p>
  
  <pre><code>function nepaliBuddha() {
      var a = 20;
  
      return function buddhaNepal() {
          console.log(a); 
      }
  }
  
  var closure = nepaliBuddha();
  
  closure(); // logs 20
  </code></pre>
  
  <ol>
  <li><p>Now when we invoke <code>closure</code> output is <code>20</code>. This proves that the internal scope property (<code>[[scope]]</code>) was assigned to the inner function where it was defined or say when declared.If this wasn't assigned at declaration ,there was no way to log 20 as it gets invoked in different context</p></li>
  <li><p>Invoking <code>closure()</code> the scope chain of a function context is created at function call and consists of the <strong>activation object or VO</strong> of the current context and the internal <code>[[scope]]</code> property of this function.</p></li>
  <li><p>Invocation also creates <code>[[scope]]</code> property , this means that internal scope property is created at declaration as well as at execution isn't it? </p></li>
  <li><p>Usually the definition says the <code>[[scope]]</code> property gets created at run time or at function call but this isn't true as <code>[[scope]]</code> property is already assigned at declaration as well.</p></li>
  <li><p>What I think is the <code>[[scope]]</code> property might get updated after execution of function, is it? Please give clear definition of [[scope]] internal property. How and when it is created at declaration time or at execution time or at both time.</p></li>
  </ol>