In this section, we are going to learn how to work with function parameters in multiple scenarios, including optional parameters, default parameters, and rest parameters.
Working with function parameters
Trailing commas in function arguments
Trailing commas are commas that are used after the final argument of a function. Using a comma after the last parameter of a function can be useful because it is very common to forget a comma when we modify an existing function by adding additional parameters.
For example, the following function only takes one parameter and doesn't use trailing commas:
function greetWithoutTralingCommas(
name: string
): string {
return 'Hi! ${name}';
}
Some time after the initial implementation...