mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 10:22:23 +00:00
完善下表述
原表述可能有误导,完善了下
This commit is contained in:
parent
4123978a0a
commit
9e86918b4a
@ -757,7 +757,7 @@ async function f() {
|
||||
// b
|
||||
```
|
||||
|
||||
上面代码中,`createAsyncIterable()`返回一个异步遍历器,`for...of`循环自动调用这个遍历器的`next`方法,会得到一个 Promise 对象。`await`用来处理这个 Promise 对象,一旦`resolve`,就把得到的值(`x`)传入`for...of`的循环体。
|
||||
上面代码中,`createAsyncIterable()`返回一个拥有异步遍历器的对象,`for...of`循环自动调用这个对象的异步遍历器的`next`方法,会得到一个 Promise 对象。`await`用来处理这个 Promise 对象,一旦`resolve`,就把得到的值(`x`)传入`for...of`的循环体。
|
||||
|
||||
`for await...of`循环的一个用途,是部署了 asyncIterable 操作的异步接口,可以直接放入这个循环。
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user