主题
技术英语 10 分钟 - 2026-06-15
今日目标
读懂 async function 和 await 在 JavaScript 文档里的基础表达。
来源类型:MDN browser JavaScript
原文
来源主题:async function and await
An async function returns a Promise, even when it returns a plain value.Use await to wait for the Promise and get its fulfilled value.If the Promise is rejected, await throws the rejection reason.参考:MDN Web Docs,JavaScript async function and await。
人话意思
第一句说:只要函数前面有 async,它返回的就不是一个普通值,而是一个 Promise。
就算你在函数里写的是 return a plain value,外面拿到的也会被包成 a Promise。
第二句说:用 await 等这个 Promise 完成,然后拿到它真正成功后的值。
第三句提醒你:如果这个 Promise 失败了,await 会把失败原因抛出来,所以它经常和 try catch 一起出现。
关键词
- async function: 异步函数,调用后会返回 a Promise
- returns a Promise: 返回一个 Promise
- plain value: 普通值,比如字符串、数字、对象
- wait for: 等待某个异步结果
- fulfilled value: 成功完成后的值
- rejected: 失败、被拒绝
- throws the rejection reason: 抛出失败原因
句子拆解
An async function returns a Promise, even when it returns a plain value.主语是:
An async function动作是:
returns返回的东西是:
a Promise后半句 even when it returns a plain value 是补充条件,意思是“即使它返回的是普通值”。
整句可以按技术文档语感理解成:
只要函数是 async,调用它时就先按 Promise 来处理,别以为能直接拿到普通值。
Use await to wait for the Promise and get its fulfilled value.这是命令句,省略了主语 you。
核心动作是:
Use await目的有两个:
to wait for the Promiseand get its fulfilled value看到 to 后面接动词时,很多时候可以先按“为了……”理解。
If the Promise is rejected, await throws the rejection reason.前半句是条件:
If the Promise is rejected后半句是结果:
await throws the rejection reason这里的 throws 在代码语境里不是“扔东西”,而是“抛出错误 / 异常”。
今天记住一句
An async function returns a Promise.以后看到 async function,先别急着看里面返回了什么,先记住:调用结果按 Promise 处理。
30 秒小练习
把下面这句翻成中文:
Use await to get the fulfilled value from the Promise.提示:fulfilled value 是“成功完成后的值”,from the Promise 是“从这个异步结果里”。
完成记录
- [ ] 看完原文
- [ ] 看完拆解
- [ ] 完成 30 秒小练习