Callbacks — image via unsplash
What Is a Callback?
Simply put: A callback is a function that is to be executed after another function (normally asynchronous) has finished executing — hence the name ‘call back’.
That’s a lot of words. Lets look at some examples to break this down a little more.
Why Do We Need Callbacks?
As you would expect, the function first is executed first, and the function second is executed second — logging the following to the console:
All good so far.