What is the problem with this code
var a=function()
{
setInterval(function(){document.write("a");},1000);
}
function b(callback)
{
callback();
alert(2);
}
b(a); // alert 2
It should not not show me the alert because the call not over yet?
The code is running as expected. SetInterval doesn’t hold the execution for rest of the code it fires assigned function after specified time.
So you will get alert and then document.write.