Skip to content

Instantly share code, notes, and snippets.

@peter
Created April 7, 2018 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter/2b16fb75e403c9d1cd9cdbcc84ed257b to your computer and use it in GitHub Desktop.
Save peter/2b16fb75e403c9d1cd9cdbcc84ed257b to your computer and use it in GitHub Desktop.
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