January 2019
Beginner
210 pages
4h 47m
English
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. A function that accepts functions as parameters (callbacks) or returns functions is known as a higher-order function.
Callback are usually anonymous functions. They can be declared before they are passed to the higher-order function, as demonstrated by the following example:
var myCallback = function() { // callback console.log("foo");}function bar(cb: () => void) { // higher order function console.log("bar"); cb();}bar(myCallback); // prints "bar" then prints "foo"
Callbacks can also be declared inline, at the same ...
Read now
Unlock full access