Skip to content

Instantly share code, notes, and snippets.

@reoxb
Created November 19, 2020 17:50
Show Gist options
  • Save reoxb/258028f3ca98082dcfa35fc0f6b71b32 to your computer and use it in GitHub Desktop.
Save reoxb/258028f3ca98082dcfa35fc0f6b71b32 to your computer and use it in GitHub Desktop.
Async/await Madrid JS DayES
(async function () {
const a = await asyncFunction(2)
const b = await asyncFunction(a)
const c = await asyncFunction(b)
const d = await asyncFunction(c)
console.log(d);
})()
function asyncFunction(x, fn){
return new Promise(function (resolve, reject) {
setTimeout(() => {
resolve(x * x)
}, 100);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment