Callback function and check if parameter is defined - Javascript Function

Javascript examples for Function:Function Argument

Description

Callback function and check if parameter is defined

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from  w w  w. j  a  v a  2s  .c o  m
function callback(message) {
  if (message !== undefined) {
      console.log('message is defined');
  } else {
     console.log('message is undefined');
    }
}
(function () {
  callback('test');
  callback();
})();
    });

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

Related Tutorials