Skip to content

Instantly share code, notes, and snippets.

@daltonmenezes
Created March 19, 2020 02:05
Show Gist options
  • Save daltonmenezes/7a5c8824e17a621d900bf4f4f0018f64 to your computer and use it in GitHub Desktop.
Save daltonmenezes/7a5c8824e17a621d900bf4f4f0018f64 to your computer and use it in GitHub Desktop.
A delay/sleep function for javascript
function delay(time) {
return new Promise(resolve =>
setTimeout(resolve, time)
)
}
(async () => {
await delay(1000)
console.log('It takes 1 second to be executed.')
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment