Last active
May 25, 2021 09:46
-
-
Save anttispitkanen/528c5d20b8319aa8aaa8f4418eb9a5be to your computer and use it in GitHub Desktop.
What happens to the first async function (waitAndReturn) invocation?
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
const waitAndReturn = (ms, msg) => | |
new Promise(resolve => { | |
setTimeout(() => { | |
resolve(msg); | |
}, ms); | |
}); | |
const foo = () => { | |
waitAndReturn(5000, 'First').then(msg => console.log(msg)); | |
return waitAndReturn(300, 'Second'); | |
}; | |
const main = async () => { | |
console.log(await foo()); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment