NodeJS - setTimeout(fn,0) vs setImmediate(fn)

前端 未结 9 1338
暖寄归人
暖寄归人 2020-12-07 13:23

What is the difference between those two, and when will I use one over the other?

9条回答
  •  我在风中等你
    2020-12-07 13:33

    setTimeout(fn,0) can be used for preventing the browser from freezing in massive update. for example in websocket.onmessage, you may have html changes, and if messages keep coming, the browser may freeze when using setImmidiate

提交回复
热议问题