Typing functions
function multiply(a: number, b: number): number {
return a * b;
}Reusable function type
function sum(a: number, b: number): number {
return a + b;
}
function modulo(a: number, b: number): number {
return a % b;
}type BinaryOperator = (a: number, b: number) => number;
const subtract: BinaryOperator = (a, b) => a - b;The void type
void typeOptional and default arguments
Resources
Last updated