setTimeout
schedules the function to be called some time later. It does not affect, and in fact has nothing to do with, the code executing in the current call stack.
By the time the setTimeout
callback runs, the previous call already finished; it is not on the call stack.
Therefore, you don't get a stack overflow.