What are the basic rules for JavaScript parameters?

A JavaScript function is a code that performs a particular task. The function parameters are the name list in the function definition. Parameters are also known as formal parameters or formal arguments.

We can follow the syntax below to declare parameters.

Syntax

function functionName(param1, param2)
{
}

When there is no value for a parameter, a default value comes in place.

Rules

  • Declare the default parameters as the final ones to avoid an error.
  • The JavaScript function definition does not specify a parameter type.
  • The JavaScript function does not check the input argument type.
  • The JavaScript function does not check the number of input arguments.