File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ for(let value of delegatingIterator) {
412
412
413
413
```
414
414
415
- 上面代码中,delegatingIterator是代理者,delegatedIterator是被代理者。由于` yield* delegatedIterator ` 语句得到的值,是一个遍历器,所以要用星号表示。
415
+ 上面代码中,delegatingIterator是代理者,delegatedIterator是被代理者。由于` yield* delegatedIterator ` 语句得到的值,是一个遍历器,所以要用星号表示。运行结果就是使用一个遍历器,遍历了多个Genertor函数,有递归的效果。
416
416
417
417
下面是一个稍微复杂的例子,使用yield* 语句遍历完全二叉树。
418
418
Original file line number Diff line number Diff line change 18
18
19
19
上面代码在代码块之中,分别用let和var声明了两个变量。然后在代码块之外调用这两个变量,结果let声明的变量报错,var声明的变量返回了正确的值。这表明,let声明的变量只在它所在的代码块有效。
20
20
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
+
21
35
下面的代码如果使用var,最后输出的是9。
22
36
23
37
``` javascript
Original file line number Diff line number Diff line change 10
10
- Sayanee Basu, [ Use ECMAScript 6 Today] ( http://net.tutsplus.com/articles/news/ecmascript-6-today/ )
11
11
- Ariya Hidayat, [ Toward Modern Web Apps with ECMAScript 6] ( http://www.sencha.com/blog/toward-modern-web-apps-with-ecmascript-6/ )
12
12
- 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的一些“轻量级”的特性介绍
13
14
- Domenic Denicola, [ ES6: The Awesome Parts] ( http://www.slideshare.net/domenicdenicola/es6-the-awesome-parts )
14
15
- Nicholas C. Zakas, [ Understanding ECMAScript 6] ( https://github.com/nzakas/understandinges6 )
15
16
- Justin Drake, [ ECMAScript 6 in Node.JS] ( https://github.com/JustinDrake/node-es6-examples )
You can’t perform that action at this time.
0 commit comments