Functions
What is it
Function Declaration
export function fnStatement(a: number, b: number): number { return a + b; }
Function Expression
const addNumbers = (a: number, b: number): number => a + b;
Breakdown
- (): stringis a- return type- Represents type of the valuethat is returned from a function
 
- Represents type of the 
- (param: int)represents the parameters of the function, where the type is an- integer- Parametersneed their own typing
 
Optionals
// void return type function messageLogger(message: string): void { console.log(message); } // primitive return type function addNumbers(a: number, b: number): number { return a + b; } // Optional Parameter `y` function newFunc(x: number, y?: number) { ... } // Default Parameter function newFunc(name: string = "you"){ ... }