typescript arrow function type code example
Example 1: generic arrow function typescript
const foo = <T extends unknown>(x: T) => x;
Example 2: arrow function in typescript
const/let <FunctionName> = (params: type) :<ReturnType> =>{
....
};
const PrintName = (name: string): string => {
return console.log("my name is " , name) ;
}
Example 3: typescript arrow function
let sum = (x: number, y: number): number => {
return x + y;
}
sum(10, 20);
Example 4: arrow function in ts
var getResult = (username: string, points: number): string => {
return `${ username } scored ${ points } points!`;
};
getResult('joyous jackal' , 100);