Skip to content

Instantly share code, notes, and snippets.

View alex-w-dev's full-sized avatar
🤣
I may be slow to respond.

Alexander Chertkov alex-w-dev

🤣
I may be slow to respond.
View GitHub Profile
@alex-w-dev
alex-w-dev / intex.js
Last active March 30, 2021 08:54
Java Script async sleep - make timeout for some seconds in async function
// sleep function
function sleep(timeout) {
return new Promise(res => setTimeout(res, timeout || 1000))
}
// example:
(async () => {
await sleep(3000);
console.log('this code will run after 3 seconds')
})()