Javascript – Sleep using native construction

Spread the love

Sometimes in javascript need to use sleep. It’s not a good practice (maybe good way – change some code?), but if you found this article you know, how it use and need only construction)

If you use the async function, you can use

await new Promise(function(resolve,reject){setTimeout(resolve,5000);});

where 5000 – time in milliseconds.

 

Добавить комментарий