One fine morning your mom tells you something.
“Listen! once you are done with your breakfast, make sure you fill up every empty water bottle and put them in the refrigerator “.
So basically you have been asked to do something once something else is done.This is how callbacks work.
Mom! i am having my breakfast Mom! i have filled up the water bottles
When to use Callbacks?
Passing arguments into callbacks
In some cases, we will need to pass arguments to the callback function. Let’s see an example
The result is - 25
When you have callback inside a callback inside another callback and so on, then the code is quite difficult to read aswell as messy. This condition is known as Callback hell. Let’s look at an example code with Callback hell
Happy Coding !!!!!