The January callback function ensures that all javascript statements are executed line by line without
a callback function.
It's possible that one line of code is run without the completion of the previous line.
This can create errors especially when dealing with multiple animation sequences.
Let's take a look at an example.
Here we have a script that hides an element with the click of a button
once the element is hidden.
An alert appears.
Note that the alert only appears once the height animation event has completed.
This is an example of an animation that uses the callback function will run that script one more time
once we clicked the hide button.
The square disappears in the alert pops up.
This here is the syntax for the callback function it's simply the word function with an open and close
bracket.
Let's see what would happen if we did not have the callback function in place
so we remove the callback function and we'll refresh the page.
Now when we put the hide button the alert appears instantly and at the same time the square disappears.
So you can see that both events occur simultaneously which is undesirable.
You typically want
each event to execute one after the other.
And for that reason the callback function is is quite important and very often used.