Javascript check arguments for zero value - Javascript Function

Javascript examples for Function:Function Argument

Description

Javascript check arguments for zero value

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//w  ww . j a va  2s.co m
"use strict";
function zeroCheck(arg1,arg2) {
    var i, argsLen = arguments.length;
    for (i = 0; i <= argsLen; i += 1) {
        if (arguments[i] === 0) {
            arguments[i] = 1; 
        }
    }
    console.log(arg1); // arg1 = 0
}
zeroCheck(0,2);
    });

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

Related Tutorials