Accepting Either One or No Arguments : Function : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Function »

 

Accepting Either One or No Arguments



<html>
<head>
  <title>JavaScript Unleashed</title>
  <script type="text/javascript">
  <!--
    function welcomeMessage(userName) {
      if (userName != null) {
        document.writeln("Hello, " + userName);
      }else{
        document.write("variable "userName" would show : ");
        document.writeln(userName);
      }
    }
  // -->
  </script>
</head>
<body>
  <script type="text/javascript">
  <!--
    document.writeln("First call to welcomeMessage(),n");
    welcomeMessage("Mr.");
    document.writeln("<HR>nSecond call to welcomeMessage(),n");
    welcomeMessage();
  // -->
  </script>
</body>
</html>



           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Function