Assuming a JavaScript function with parameters:
function minhaFuncao (param1, param2, param3) {
// fazer algo ...
}
And then using it as follows:
var param1 = "bubu";
minhaVariavel = minhaFuncao (param1);
or
var param1 = 30,
param2 = true;
minhaFuncao (param1, param2);
Question
How can we check, within the function, if a parameter of any type was provided to avoid using it?
Example using the parameter without having received the same:
function minhaFuncao (param1) {
alert("BuBu diz: " + param1);
}
minhaFuncao();
Note: It does not really matter the type of parameters, it is important to know if they were received to avoid problems in logic or to act accordingly.