Create function with default value - Javascript Function

Javascript examples for Function:Function Argument

Description

Create function with default value

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <form name="form1">
          Key: /*  w  w w  . jav  a  2  s  .  c  om*/
         <input type="text" name="text1" value="author"> 
         <input type="button" name="button1" value="Test"> 
      </form> 
      <script>
      document.form1.button1.onclick = function() {
        console.log(getQuerystring(document.form1.text1.value));
        console.log(getQuerystring(document.form1.text1.value,'default'));
      }
      function getQuerystring(key, default_) {
          console.log(key);
          console.log(default_);
      }
    
      </script>  
   </body>
</html>

Related Tutorials