1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-25 11:12:21 +00:00

Merge pull request #610 from cntanglijun/gh-pages

少了一个"个"字
This commit is contained in:
Ruan YiFeng 2018-02-25 21:57:29 -06:00 committed by GitHub
commit a3514a0083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,7 +151,7 @@ g.next() // { value: 3, done: false }
g.next(2) // { value: 2, done: true }
```
上面代码中,第一`next`方法的`value`属性,返回表达式`x + 2`的值`3`。第二个`next`方法带有参数`2`,这个参数可以传入 Generator 函数,作为上个阶段异步任务的返回结果,被函数体内的变量`y`接收。因此,这一步的`value`属性,返回的就是`2`(变量`y`的值)。
上面代码中,第一`next`方法的`value`属性,返回表达式`x + 2`的值`3`。第二个`next`方法带有参数`2`,这个参数可以传入 Generator 函数,作为上个阶段异步任务的返回结果,被函数体内的变量`y`接收。因此,这一步的`value`属性,返回的就是`2`(变量`y`的值)。
Generator 函数内部还可以部署错误处理代码,捕获函数体外抛出的错误。