typescript optional parameters in constructor code example
Example 1: how to define optional parameter in typescript
function functionName(par1: number, par2?: number) {
}
Example 2: typescript make function argument optional
function multiply(a: number, b: number, c?: number): number {
if (typeof c !== 'undefined') {
return a * b * c;
}
return a * b;
}