I have this code snippet for hide a paragraph and alert a message after that
$(document).ready(function(){
$("p").hide("slow");
alert("stop");
});
This doesn't work as I wanted to work. It gives the alert before finish hiding the paragraph. I understand that it can be corrected by using a call back function.
My question is if JavaScript is single threaded why doesn't it wait until finish hiding the paragraph to alert the message? If it is single threaded shouldn't that JavaScript first finish the hiding process and then come to alerting part?
Can someone please explain it.