Access variables in closures if there are local variables with the same name - Javascript Data Type

Javascript examples for Data Type:Variable Scope

Description

Access variables in closures if there are local variables with the same name

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*  www. ja  v a2s .  c  o m*/
function outerFunction(s) {
  var someString = 'Hai!';
  function innerFunction() {
    var someString='Hello';
    console.log(someString);
  }
  innerFunction();
}
outerFunction();
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials