Javascript execution order with setTimeout()

倾然丶 夕夏残阳落幕 提交于 2019-12-04 03:18:55
Jakob

The first of your guesses is the correct one: testB() is queued up to execute after doLong() and anything else it called have finished.

If it takes more than one second for testA to finish, testB will simply have to wait.

Also, you should write setTimeout(testB, 1000) rather than setTimeout('testB()', 1000). Sending a string to setTimeout is, like using eval, generally considered evil and will make you enemies ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!