Functions are how we structure behavior. In TypeScript, you can describe parameter types and return types so that invalid calls are caught early:
function greet(name: string): string {
return `Hello, ${name}!`;
}You can also let the compiler infer types from values and contexts, making callbacks and arrow functions pleasant to write.
In this category, you'll:
name?: string) and default (width = 100) parametersBy the end, you'll be comfortable reading and writing function signatures, choosing when to be explicit, and relying on inference where it helps clarity.