Why does this code print 1 3 2 as we didn't give the time in settimeout

function dosomething(done){
console.log(1.START);
settimeout(done , 0);
}

dosomething(( )=>{
console.log(2.in between);
});

console.log(3. end);

Hi @aditya010sh_cda2cad8fd454417,
If you call setTimeout() with a time of 0 ms, the function you specify is not invoked right away . Instead, it is placed on a queue to be invoked “as soon as possible” after any currently pending event handlers finish running.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.