typescript arrow function code example
Example 1: arrow function in typescript
//prototype
const/let = (params: type) : =>{
....
};
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
Example 3: generic arrow function typescript
const foo = (x: T) => x;
Example 4: arrow function in ts
// ES6: With arrow function
var getResult = (username: string, points: number): string => {
return `${ username } scored ${ points } points!`;
};
getResult('joyous jackal' , 100);