Created
July 23, 2018 17:15
-
-
Save obbaeiei/ad41436efd76e704e6190a55210f31ed to your computer and use it in GitHub Desktop.
Async/Await example02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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