funzione freccia dattiloscritto
let sum = (x: number, y: number): number => {
return x + y;
}
sum(10, 20); //returns 30
funzione freccia in dattiloscritto
//prototype
const/let <FunctionName> = (params: type) :<ReturnType> =>{
....
};
const PrintName = (name: string): string => {
return console.log("my name is " , name) ;
}
generic arrow function typescript
const foo = <T extends unknown>(x: T) => x;
funzione freccia in ts
// ES6: With arrow function
var getResult = (username: string, points: number): string => {
return `${ username } scored ${ points } points!`;
};
getResult('joyous jackal' , 100);