Javascript functions can be called with any number of parameters, regardless of the number of parameter names in the function definition. Because a function is of a loose type, it cannot declare the type of the expected parameter, and it is legal to pass any type of parameter to any function.
When the number of parameters that call a function is less than the number of declared parameters, other parameters have an undefined value. Writing such a function is often useful: some parameters are optional and can be ignored when calling the function. To do this, you must be able to assign a reasonable default value for ignored parameters. For example:
<HTML>
In this example, if a has been defined and is not null, it returns a, even if a is null. Otherwise, it returns a new empty array.
When using optional parameters to design functions, make sure that the optional parameters are placed at the end of the parameter list so that they can be ignored.