Getting return value of function object - Javascript Function

Javascript examples for Function:Function Return

Description

Getting return value of function object

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function a() {
    //do something
    if (true) {//from  ww w  .  j av a  2 s .co  m
        //do other things
    } else {
        return false;
    }
    //Do final things
    return true;
}
function b() {
    var p = a();
    console.log(p); //will return true
}
b();

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

Related Tutorials