Skip to content

Instantly share code, notes, and snippets.

@obbaeiei
Created July 23, 2018 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obbaeiei/ad41436efd76e704e6190a55210f31ed to your computer and use it in GitHub Desktop.
Save obbaeiei/ad41436efd76e704e6190a55210f31ed to your computer and use it in GitHub Desktop.
Async/Await example02
async function main() {
console.log(1)
await delay(1000)
console.log(2)
await delay(2000)
console.log(3)
}
function delay(ms) {
return new Promise((resolve)=>{
setTimeout(()=>{
resolve()
}, ms)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment