title: VariableEnvironment's functions
body: <h1>Variable/Lexical Environment component of execution context</h1>
  
  <p><strong>Question 1</strong>:</p>
  
  <p>For what <code>VariableEnvironment</code> component of exection context is needed?
  As said in spec LexicalEnvironment component</p>
  
  <blockquote>
    <p>used to resolve identifier references made by code
    within this execution context.</p>
  </blockquote>
  
  <p>But <code>VariableEnvironment</code> component used to </p>
  
  <blockquote>
    <p>holds bindings created by VariableStatements and FunctionDeclarations
    within this execution context.</p>
  </blockquote>
  
  <p>Ok, but evaluation of <code>PrimaryExpression:Identifier</code> is execution with <code>LexicalEnvironment</code> component, not <code>VariableEnvironment</code> of running execution context:</p>
  
  <blockquote>
    <ol>
    <li>Let env be the running execution context‘s LexicalEnvironment.</li>
    <li>If the syntactic production that is being evaluated is contained in a strict mode code, then let strict be true, else let strict be false.</li>
    <li>Return the result of calling GetIdentifierReference function passing env, Identifier, and strict as arguments.</li>
    </ol>
  </blockquote>
  
  <p>Thus is VariableEnvironment need for bindings storage only? </p>
  
  <p>Establishing function context is occuring as:
  <a href="http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.3" rel="nofollow"><strong>sec. 10.4.3</strong></a></p>
  
  <blockquote>
    <ol>
    <li>If the function code is strict code, set the ThisBinding to thisArg.</li>
    <li>Else if thisArg is null or undefined, set the ThisBinding to the global object.</li>
    <li>Else if Type(thisArg) is not Object, set the ThisBinding to ToObject(thisArg).</li>
    <li>Else set the ThisBinding to thisArg.</li>
    <li>Let localEnv be the result of calling NewDeclarativeEnvironment passing the value of the [[Scope]] internal property of F as the
    argument.</li>
    <li>Set the LexicalEnvironment to localEnv.</li>
    <li>Set the VariableEnvironment to localEnv.</li>
    <li>Let code be the value of F‘s [[Code]] internal property.</li>
    <li>Perform Declaration Binding Instantiation using the function code code and argumentsList as described in 10.5.</li>
    </ol>
  </blockquote>
  
  <p>Where at step 9 bindings add to a <code>VariableEnvironment</code> only. At step 5 <code>[[Scope]]</code> internal property indicates to outer <code>LexicalEnvironment</code>. Thus i have question</p>
  
  <p><strong>Question 2</strong>:
  Is it true that just after creation of execution context of function code <code>LexicalEnvironement</code>'s initial environment record contains the same bindings that environment record of outer <code>LexicalEnvironment</code>? </p>
  
  <p>Consider the following code snippet into the global code?</p>
  
  <h1>Example of function code</h1>
  
  <pre><code>function bar(){
      var b={b:'b'}
      var o={o:'o'}
  }
  bar();
  </code></pre>
  
  <p><strong>Question 3:</strong></p>
  
  <p>Is it true that just after creation of <code>bar</code> execution context before the start of execution function code <code>VariableEnvironment</code>'s environment record will be contain <code>bar--&gt;function bar(){ ... }, b--&gt;{b:'b'}, o--&gt; {o:'o'}</code>, but <code>LexicalEnvironment</code>'s environment record </p>