What is the correct way to define a default parameter in a TypeScript function?
TypeScript AssociateEasy
TypeScript Associate — Easy
What is the correct way to define a default parameter in a TypeScript function?
Explanation
In TypeScript, the correct way to define a default parameter in a function is by using the syntax "function greet(name = 'World'): string" or "function greet(name: string = 'World'): string". Both options A and B are correct because they follow the proper format for setting a default parameter in a TypeScript function.