Create your own async function handler - Javascript Function

Javascript examples for Function:Function Async

Description

Create your own async function handler

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width"> 
   </head> 
   <body> 
      <script>
function asyncFunction(time, callback){
  setTimeout(function() {// w ww . ja va 2  s .  c om
      callback('Bye!')
  }, time);
}
function getMessage(){
console.log('Hello!');

asyncFunction(2000, function(message){
  console.log(message);
});
}
getMessage();

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

Related Tutorials