mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
修改iterator/Symbol.iterator
This commit is contained in:
parent
0c21b61c55
commit
9344196b46
@ -155,6 +155,14 @@ let obj = {
|
||||
|
||||
```
|
||||
|
||||
对于类似数组的对象,部署Iterator接口,有一个简便方法,就是`Symbol.iterator`方法直接引用数值的Iterator接口。
|
||||
|
||||
```javascript
|
||||
|
||||
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
||||
|
||||
```
|
||||
|
||||
如果`Symbol.iterator`方法返回的不是遍历器,解释引擎将会报错。
|
||||
|
||||
```javascript
|
||||
|
@ -256,8 +256,8 @@ normalize方法可以接受四个参数。
|
||||
|
||||
```javascript
|
||||
|
||||
'\u004F\u030C'.normalize(NFC).length // 1
|
||||
'\u004F\u030C'.normalize(NFD).length // 2
|
||||
'\u004F\u030C'.normalize('NFC').length // 1
|
||||
'\u004F\u030C'.normalize('NFD').length // 2
|
||||
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user