Created
April 7, 2018 04:58
-
-
Save peter/2b16fb75e403c9d1cd9cdbcc84ed257b to your computer and use it in GitHub Desktop.
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
function syncBar () { | |
console.log('in syncBar') | |
return 'syncBar' | |
} | |
function asyncBar () { | |
console.log('in asyncBar') | |
return Promise.resolve('asyncBar') | |
} | |
async function foo () { | |
console.log('in foo') | |
const resultSync = await syncBar() | |
const resultAsync = await asyncBar() | |
console.log('in foo result', resultSync, resultAsync) | |
return [resultSync, resultAsync] | |
} | |
foo() | |
// => in foo | |
// => in syncBar | |
// => in foo result syncBar asyncBar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment