ECMAScript6 给对象实现 iterator 方法
来源:互联网 发布:网络流行文化 编辑:程序博客网 时间:2024/06/15 05:28
Object.prototype[Symbol.iterator] = function(){let index = 0,_this = this;return {next: function(){return index < _this.length ? { value: d[index++], done: false }:{ value: undefined, done:true };}}}
const d = {'0': 't','1': 'a','2': 'o',length: 3}var itD = d[Symbol.iterator]();console.log(itD.next());console.log(itD.next());console.log(itD.next());console.log(itD.next());
阅读全文
0 0
- ECMAScript6 给对象实现 iterator 方法
- ECMAScript6(14):iterator 迭代器
- ECMAscript6快速入门-iterator
- ECMAScript6笔记:Promise对象
- ECMAScript6(15):Promise 对象
- ES6 对象实现 Iterator 接口
- ECMAScript6标准Iterator和for...of循环
- ECMAScript6笔记:Iterator和for...of循环
- ECMAScript6笔记:对象的扩展
- ECMAScript6(8):对象的扩展
- ECMAScript6(ES6)标准之对象Object扩展方法及新特性
- Iterator 接口的使用 所有的Collection接口类都有一个iterator方法 ,Iterator对象的删除
- ECMAScript6
- ECMAScript6
- ECMAScript6
- ECMAScript6
- ECMAScript6
- ECMAScript6
- Python 3.5安装pyMySQL错误“error: Microsoft Visual C++ 14.0 is required…”
- C#开发:openfiledialog的使用
- SimpleDateFormat线程不安全及解决办法
- spring-cloud 微服务框架集合 Eureke 服务注册于发现
- 在Centos中升级Jenkins版本
- ECMAScript6 给对象实现 iterator 方法
- UVa 712 S-Trees——进制转化
- 产品经理业务流程图的绘制流程
- Android
- 每逢高考必有雨?来看看历年来高考期间天气大数据/智库2861
- 快速矩阵幂
- Keil 链接错误 Error: L6406E: No space in execution regions with .ANY selector matching
- 一次被Nginx、openVPN、CentOS来回折腾的记录
- C#中判断SQL Server数据库是否连接成功