Now that we have seen how to work with functions, we will explore how we can use them, together with some native objects, to write asynchronous applications.
In TypeScript, functions can be passed as arguments to another function. The function passed to another as an argument is known as a callback. Functions can also be returned by another function. The functions that accept functions as parameters (callbacks) or return functions as an argument are known as higher-order functions. Callbacks are usually anonymous functions.
var foo = function() { // callback console.log('foo'); } function bar(cb : () => void) { // higher order function console.log('bar'); cb(); } bar(foo); // prints 'bar' then prints 'foo'