title: JavaScript: Accessing variable/property of middle/outer functions in nested functions
body: <p>I'm learning Javascript, and had this question. Here's some sample code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var xq = false;
  var fooyy = function ttt() {
    var xq = false;
    baryy = function() {
      var xq = true;
      console.log(xq);
      console.log(ttt);
      console.log(fooyy);
      console.log(ttt.xq);
      console.log(fooyy.xq);
      console.log(window.xq);
    }();
  };
  
  fooyy();
  console.log(xq);
  console.log(fooyy.xq);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Looking at the output, my question is, so does it mean that from an inner nested function, properties and variables of outer functions can't be accessed (both in the cases of having the same name and otherwise)? Or if they can, could you explain how and why? (I see that the local and global variables are accessible) Thanks!</p>