Functions
Learn Functions (Module 2 · TypeScript, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Functions, parameters and return types • A function in TS declares parameter types and a return type . Think of a vending machine: you must insert the right coins (parameters) and know what comes out (return type). • Optional parameters use ? (and must come last); default parameters use =; rest parameters (...args) gather extra arguments into an array.