JavaScript function parameters
JavaScript functions do not perform any checks on the values of parameters (arguments).
Function explicit parameters and hidden parameters (arguments)
In the previous tutorial, we have learned about the explicit parameters of the function:
functionName(parameter1, parameter2, parameter3) {
code to be executed
}
Explicit function parameters Listed when the function is defined.
Function hidden parameters (arguments) are the real values passed to the function when the function is called.
Parameter Rules
The parameters do not specify data types when defining JavaScript functions.
JavaScript function does not detect hidden parameters (arguments).
The JavaScript function does not detect the number of hidden parameters (arguments).
Default parameters
If a function is called without parameters, the parameters will be set to: undefined by default
Sometimes this is acceptable, but it is recommended to set a default value for the parameters:
Example
function myFunction(x, y) {
if (y === undefined) {
y = 0;
}
}