how to define type for arrow function in typescript code example
Example 1: arrow function in typescript
//prototype
const/let <FunctionName> = (params: type) :<ReturnType> =>{
....
};
const PrintName = (name: string): string => {
return console.log("my name is " , name) ;
}
Example 2: typescript arrow function
let sum = (x: number, y: number): number => {
return x + y;
}
sum(10, 20); //returns 30