Skip to content

Instantly share code, notes, and snippets.

@ShikChen
Created May 25, 2018 13:46
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 ShikChen/5443b6f1c09180bb90f235bf8db3602f to your computer and use it in GitHub Desktop.
Save ShikChen/5443b6f1c09180bb90f235bf8db3602f to your computer and use it in GitHub Desktop.
const sleep = (sec) => new Promise(resolve => setTimeout(resolve, sec * 1000))
async function foo() {
console.log(1)
await sleep(1)
console.log(2)
}
(async () => {
foo().then(() => console.log(3))
console.log(4)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment