ts return type arrow function code example
Example 1: typescript arrow function
let sum = (x: number, y: number): number => {
return x + y;
}
sum(10, 20);
Example 2: arrow function in ts
var getResult = (username: string, points: number): string => {
return `${ username } scored ${ points } points!`;
};
getResult('joyous jackal' , 100);
Example 3: function with return type in angular
greet() : number {
return "Hello, " + this.greeting;
}
Example 4: typescript annotate return type
function add(x: number, y: number): number {
return x + y;
}