Created
November 19, 2020 17:50
-
-
Save reoxb/258028f3ca98082dcfa35fc0f6b71b32 to your computer and use it in GitHub Desktop.
Async/await Madrid JS DayES
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 () { | |
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