Functions in TypeScript
A simple definition of function is a set of statements that can be invoked; however, the use and conventions of functions cannot be summarized so easily. Functions in TypeScript have greater utility than in some other languages. In addition to being invoked as normal, functions can also be given as arguments to other functions and can be returned from functions. Functions are actually a special kind of object that can be invoked. This means that in addition to parameters, functions can actually have properties and methods of their own, though this is rarely done.
Only the smallest of programs will ever avoid making heavy use of functions. Most programs will be made up of many .ts
files. Those files will typically export functions, classes, or objects. Other parts of the program will interact with the exported code, typically by calling functions. Functions create patterns for reusing your application logic and allow you to write DRY (don't repeat yourself...