Execute and run code after two function have ended - Javascript Data Type

Javascript examples for Data Type:Variable Scope

Description

Execute and run code after two function have ended

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 ww  .  j a  v  a  2  s  .  c om*/
var state = 0;
function f1() {
    state++;
    fend();
}
function f2() {
    state++;
    fend();
}
function fend() {
    if (state == 2) {
        console.log("fend called");
        state = 0;
    }
}
f2();
f1();
    }

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

Related Tutorials