Sleep in JavaScript - delay between actions

前端 未结 11 1886
别跟我提以往
别跟我提以往 2020-11-22 01:27

Is there a way I can do a sleep in JavaScript before it carries out another action?

Example:

 var a = 1+3;
 // Sleep 3 seconds before the next action         


        
11条回答
  •  鱼传尺愫
    2020-11-22 02:15

    This is my model that shows how to "sleep" or "DoEvents" in javascript using a generator function (ES6). Commented code:

    
    
    
    
    
    
    
    
    

提交回复
热议问题