We can add types to function parameters using TypeScript.
Here is a function:
function add(num1, num2) {
return num1 + num2;
}
Let us specify num1
and num2
as number
type using TypeScript.
function add(num1: number, num2: number) {
return num1 + num2;
}