mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2024-04-21 12:32:22 +00:00
add object/扩展运算符
This commit is contained in:
@@ -227,6 +227,10 @@ let obj = {
|
||||
|
||||
```javascript
|
||||
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
||||
// 或者
|
||||
NodeList.prototype[Symbol.iterator] = [][Symbol.iterator];
|
||||
|
||||
[...document.querySelectorAll('div')] // 可以执行了
|
||||
```
|
||||
|
||||
如果Symbol.iterator方法返回的不是遍历器,解释引擎将会报错。
|
||||
|
||||
Reference in New Issue
Block a user