function expression in typescript 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: typescript function type
function sayHello(name: string): string {
console.log(`Hello, ${name}`!);
}
sayHello('Bob');
Example 4: types function typescript
interface Alternate_Syntax_4_Advanced {
title: string;
callback<T extends unknown[], R = unknown>(...args?: T): R;
}