Javascript examples for Function:Function Nest
JavaScript scope within nested function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from ww w. ja v a 2 s . c o m function bar() { var x = "outer"; function foo() { console.log(x); // undefined, is not referring to the outerscope x // Due the the var hoising next: x = 'inner'; var x; console.log(x); // inner } foo(); } bar(); }); </script> </head> <body> </body> </html>