Function hoisting, nested functions - Javascript Function

Javascript examples for Function:Function Variable

Description

Function hoisting, nested functions

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() {/*from   w  w  w  .  ja  v a  2s.c  o  m*/
function foo(){{
    function bar() {
        return 3;
    }
    return bar();
    function bar() {
        return 8;
    }
}}
console.log(foo());
    });

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

Related Tutorials