Question about setTimeout that I need answer to

后端 未结 3 1978
你的背包
你的背包 2021-01-20 22:20

So we all know setTimeout waits a certain amount of time before executing something. My question is, does it wait for the above code to finish executing first, before waitin

3条回答
  •  我在风中等你
    2021-01-20 22:44

    If you setTimeout to a very small value (e.g. 1ms, possibly even zero, but haven't checked that) it will execute as soon as your main code is finished. It won't execute before your main code is finished, because JavaScript is not multi-threaded.

提交回复
热议问题