how to make a sleep in javascript?

后端 未结 9 2054
半阙折子戏
半阙折子戏 2020-12-20 23:00

Does anyone know how can I make a sleep in javascript before next line been read by the system?

example:

    1 var chkResult = Validation();
    2 /         


        
9条回答
  •  孤城傲影
    2020-12-20 23:55

    setTimeout starts a separate execution "thread" within the JavaScript interpreter. You need to pass it a function and design your scripts in such a way that the function the setTimeout runs will continue where the calling function left off--thereby simulating a sleep.

提交回复
热议问题