Skip to content

Commit 72b6fde

Browse files
committed
修改let
1 parent ed7deeb commit 72b6fde

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/generator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ for(let value of delegatingIterator) {
412412

413413
```
414414

415-
上面代码中,delegatingIterator是代理者,delegatedIterator是被代理者。由于`yield* delegatedIterator`语句得到的值,是一个遍历器,所以要用星号表示。
415+
上面代码中,delegatingIterator是代理者,delegatedIterator是被代理者。由于`yield* delegatedIterator`语句得到的值,是一个遍历器,所以要用星号表示。运行结果就是使用一个遍历器,遍历了多个Genertor函数,有递归的效果。
416416

417417
下面是一个稍微复杂的例子,使用yield*语句遍历完全二叉树。
418418

docs/let.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ b //1
1818

1919
上面代码在代码块之中,分别用let和var声明了两个变量。然后在代码块之外调用这两个变量,结果let声明的变量报错,var声明的变量返回了正确的值。这表明,let声明的变量只在它所在的代码块有效。
2020

21+
for循环的计数器,就很合适使用let命令。
22+
23+
```javascript
24+
25+
for(let i = 0; i < arr.length; i++){}
26+
27+
console.log(i)
28+
//ReferenceError: i is not defined
29+
30+
31+
```
32+
33+
上面代码的计数器i,只在for循环体内有效。
34+
2135
下面的代码如果使用var,最后输出的是9。
2236

2337
```javascript

docs/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Sayanee Basu, [Use ECMAScript 6 Today](http://net.tutsplus.com/articles/news/ecmascript-6-today/)
1111
- Ariya Hidayat, [Toward Modern Web Apps with ECMAScript 6](http://www.sencha.com/blog/toward-modern-web-apps-with-ecmascript-6/)
1212
- Dale Schouten, [10 Ecmascript-6 tricks you can perform right now](http://html5hub.com/10-ecmascript-6-tricks-you-can-perform-right-now/)
13+
- Colin Toh, [Lightweight ES6 Features That Pack A Punch](http://colintoh.com/blog/lightweight-es6-features): ES6的一些“轻量级”的特性介绍
1314
- Domenic Denicola, [ES6: The Awesome Parts](http://www.slideshare.net/domenicdenicola/es6-the-awesome-parts)
1415
- Nicholas C. Zakas, [Understanding ECMAScript 6](https://github.com/nzakas/understandinges6)
1516
- Justin Drake, [ECMAScript 6 in Node.JS](https://github.com/JustinDrake/node-es6-examples)

0 commit comments

Comments
 (0)