An optional parameter is one that a caller can include in a call to a function or method, but doesn't have to. When omitted, a default value is used instead. Optional parameters are useful when the default value is used in most cases, but still needs to be specified on occasion.
For a normal function or method, a caller must supply the number of arguments specified in the signature of the routine. However, when a function or method is declared with optional parameters, it means it's okay for a caller to omit one or more of the argument values. If the caller supplies a value for an optional parameter, the value is assigned to the parameter variable as usual. But if the caller omits a value for the corresponding argument position, the parameter is simply set to a default value instead.
Optional parameters are useful in situations where one expects that the majority of calls to the function will use the same value for that argument. Rather than forcing typical callers to include that same value in every call, the parameter can be made optional, so that callers wanting the default can simply omit the argument from the call. At the same time, in the few cases where a different value is needed, it can still be specified by just adding the extra argument.
In most languages, optional parameters must come after required parameters. When calling the function or method, the omitted parameters are at the end of the argument list. This prevents later arguments being interpreted as the value for the omitted optional parameter.
Named parameters are another way to solve this problem, as they explicitly state which parameter an argument corresponds to.