A parameter is a variable named in a function definition. When the function is invoked, arguments—the values passed to it—are assigned to parameters in order. section 3.4
Parameters appear across JavaScript function forms:
- Function declarations and function expressions can list parameters in their definitions. section 3.4
- Arrow functions use a comma-separated parameter list; parentheses are optional for one parameter but required for none or more than one. section 3.3.2
Definition versus invocation
In skulk(ninja), ninja is the parameter. Calling skulk("Hattori") passes "Hattori" as an argument, assigning that value to ninja. section 3.4
Arguments are matched to parameters by position. Extra arguments are not assigned to named parameters; access to those excess values is deferred. JavaScript permits calls with different numbers of arguments and parameters. section 3.4
Use the diagram to distinguish a parameter in a definition from an argument in a call. section 3.4
Figure 3.8. Arguments are assigned to function parameters in the order specified. Excess arguments aren’t assigned to any parameters.
The figure illustrates positional assignment and what happens to excess arguments. section 3.4
