Callbacks
Learn about the callbacks and how we can sort arrays using them.
We'll cover the following
Introduction to callbacks
A function that’s passed as an argument to another function is known as a callback. The callback can then be called from within the body of the function that it’s an argument of. Being able to call different functions from within functions makes functions even more flexible.
To see an example of this, let’s look at the following function, called bake
. This is a JavaScript example of the baking analogy we used for functions earlier. It accepts a string of ingredients as a parameter and then logs some messages to the console.
Get hands-on with 1400+ tech skills courses.