Sleep in JavaScript - delay between actions

前端 未结 11 1866
别跟我提以往
别跟我提以往 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:07

    You can use plain javascript, this will call your function/method after 5 seconds:

    setTimeout(()=> { your_function(); }, 5000);
    

提交回复
热议问题