记录一下Promise与其语法糖async、await的区别


// 例子1
async function myAsyncFn() {
  return 'some values'
}
// 等价于
function myAsyncFn() {
  return Promise.resolve('some values')
}

// 例子2
async function myAsyncFn() {
  await 'something'
}
// 等价于
function myAsyncFn() {
  return Promise.resolve('something').then(() => undefined)
}
03-05 14:49