Now that we have seen how to work with functions, we will explore how we can use them, together with some native APIs, to write asynchronous applications.
Asynchronous programming in TypeScript
Callbacks and higher-order functions
In TypeScript, functions can be passed as arguments to another function. Functions can also be returned by another function. A function passed to another as an argument is known as a callback. Functions that accept functions as parameters (callbacks) or return functions are known as higher-order functions.
Callbacks are usually anonymous functions. They can be declared before they are passed to the higher-order function, as demonstrated by the following example:
var foo = function() { // callback...