We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a67b578 commit bad0552Copy full SHA for bad0552
docs/async.md
@@ -210,18 +210,20 @@ getTitle('https://tc39.github.io/ecma262/').then(console.log)
210
211
### await 命令
212
213
-正常情况下,`await`命令后面是一个 Promise 对象。如果不是,会被转成一个立即`resolve`的 Promise 对象。
+正常情况下,`await`命令后面是一个 Promise 对象。如果不是,就返回对应的值。
214
215
```javascript
216
async function f() {
217
+ // 等同于
218
+ // return 123;
219
return await 123;
220
}
221
222
f().then(v => console.log(v))
223
// 123
224
```
225
-上面代码中,`await`命令的参数是数值`123`,它被转成 Promise 对象,并立即`resolve`。
226
+上面代码中,`await`命令的参数是数值`123`,这时等同于`return 123`。
227
228
`await`命令后面的 Promise 对象如果变为`reject`状态,则`reject`的参数会被`catch`方法的回调函数接收到。
229
0 commit comments