As we know javascript code run line by line and sometimes the current line effect is still in progress but the next line executes and this creates an error.
To prevent this, we can create callback functions.
In this example, we have used a callback parameter that is a function that will be executed and will be showing an alert message after the hide effect is completed.