title: How to access outer function variable in nested inner function in JS
body: <p>I am new to JS and having a doubt with the below example. Please see the inline comments.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function outer() {
   var x = 5;
   console.log("outer",x); // Prints 5
   console.log("-----------");
   function inner() {
    var x = 6;
    console.log("inner",x); // Prints 6
    console.log("outer",x); // Prints 6. How to print 5
    console.log("-----------");
    function _inner() {
     var x = 7;
     console.log("_inner",x); // Prints 7
     console.log("inner",x); // Prints 7. How to print 6
     console.log("outer",x); // Prints 7. How to print 5
     console.log("-----------");
    }
    _inner();
   }
   inner();
  }
  outer();</code></pre>
  </div>
  </div>
  </p>