Skip to content

Commit 7d96eb0

Browse files
committed
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
2 parents e657a67 + 2c4aab7 commit 7d96eb0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/generator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ for(let value of delegatingIterator) {
783783
784784
上面代码中,`delegatingIterator`是代理者,`delegatedIterator`是被代理者。由于`yield* delegatedIterator`语句得到的值,是一个遍历器,所以要用星号表示。运行结果就是使用一个遍历器,遍历了多个Generator函数,有递归的效果。
785785
786-
`yield*`语句等同于在Generator函数内部,部署一个`for...of`循环。
786+
`yield*`后面的Generator函数没有`return`语句,等同于在Generator函数内部,部署一个`for...of`循环。
787787
788788
```javascript
789789
function* concat(iter1, iter2) {
@@ -803,7 +803,7 @@ function* concat(iter1, iter2) {
803803
}
804804
```
805805
806-
上面代码说明,`yield*`不过是`for...of`的一种简写形式,完全可以用后者替代前者。
806+
上面代码说明,`yield*`后面的Generator函数没有`return`语句时,不过是`for...of`的一种简写形式,完全可以用后者替代前者。反之,则需要用'var value=yield* Generator函数'的形式获取'return'语句的值
807807
808808
如果`yield*`后面跟着一个数组,由于数组原生支持遍历器,因此就会遍历数组成员。
809809

0 commit comments

Comments
 (0)