I don’t know what is the best way to write it and how to… I have a function like
function myFunc(myVal1, myVal2){/*... various things ...*/};
where myVal1 and myVal2 are numbers
Sometimes I want to be able to recall the function passing only one parameter just by calling myFunc(myVal1). Doing so I want that myVal2 would have a standard value, if not declared, of 0.
I was thinking to write something
function myFunc(myVal1, myVal2){
if(myVal2 == NaN)
myVal2 = 0;
}
}
But I don’t believe that it is the right way to do it.
Thx very much for the help!
Arguments that are not set have type undefined, test for it like this.