25 - PRE and POST Arguments

by steen_hansen

HTML

<!DOCTYPE html><meta charset="utf-8" />
<title>25 Default Parameters</title>





<div id='js-div' style="width:60%">
  <a href='https://github.com/steenhansen/type-czech'  target="_blank" class='git-hub'>GitHub Package</a>
  <div id='js-code'>the javascript</div>
  <br>


























</div>


<div id="the-explanation" style="width:40%">
  <div class='an-explantion'>25 - Default Parameters</div>
  <div id='explanation-text'> 
    <br>
     TypeCzech cannot see default parameters, as it runs before the actual function does, 
     but it can see how many parameters there are
     in a function call. So the trick is to verify different signatures according to the 
     number of parameters. In the upper example to the left, a ['string', 'number'] is
     checked for when there are two parameters. If there is only one parameter then it 
     must be a 'string'. Otherwise no type checks, which results in both defaults of
      'Denzel Washington 66' being used. So defaults are assumed correct.
     <br><br>
     The lower example to the left, always expects the first parameter to be a 'string'.
     The second parameter is ignored as an extra parameter.
     <br><br>

  </div>

  <div id="console-log"  >
    <div class='a-title'>Console Output</div>
    <div id='log-text'></div>
    <br>
  </div>





  
<!--            ----------------TYPE 1--------------------------       -->
<script src="https://cdn.jsdelivr.net/gh/steenhansen/type-czech@latest/web-resources/consolelog.js"></script>
<script src="https://cdn.jsdelivr.net/gh/steenhansen/type-czech@latest/web-resources/TypeCzech.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/steenhansen/type-czech@latest/web-resources/type-czech.css">
<!--            ---------------TYPE 1s---------------------------       -->
<div id='js-fiddles'>
  <a title="Example-Contents" href="https://jsfiddle.net/steen_hansen/1Lshcept/?Example-Contents" target="_blank">Contents</a>


  <a...