当前位置:网站首页>ES6 从入门到精通 # 14:迭代器 Iterator 的用法
ES6 从入门到精通 # 14:迭代器 Iterator 的用法
2022-08-09 22:39:00 【凯小默】
说明
ES6 从入门到精通系列(全23讲)学习笔记。
Iterator
Iterator 是一种的新的遍历机制:
- 迭代器是一个接口,能快捷的访问数据,通过
Symbol.iterator
来创建迭代器,通过迭代器的next()
获取迭代之后的结果 - 迭代器是用于遍历数据结构的指针(数据库的游标)
使用迭代:
const kaimo = ["k", "a", "i", "m", "o"];
console.log(kaimo);
// 创建新的迭代器
const ite = kaimo[Symbol.iterator]();
console.log(ite);
// done 为 true 表示遍历完成
console.log(ite.next());
console.log(ite.next());
console.log(ite.next());
console.log(ite.next());
console.log(ite.next());
console.log(ite.next());
边栏推荐
猜你喜欢
《GB5084-2021》PDF下载
三:OpenCV图片颜色通道数据转换
Gumbel distribution of discrete choice model
金仓数据库 KingbaseGIS 使用手册(6.4. 几何对象存取函数)
多商户商城系统功能拆解24讲-平台端分销会员
全面解析FPGA基础知识
首席信息官如何将可持续性和技术结合起来
Gartner's global integrated system market data tracking, hyperconverged market growth rate is the first
Travel with Shengteng: See all the AI attractions in Jinling City in one day
防火墙之系统防护
随机推荐
十位时间戳转化成时间
33. Fabric通道、组织、节点、权限间关系
How to match garbled characters regularly?
IT传奇人物菲尔德的转型经验教训及给CIO的建议
ALV报表总结2022.8.9
【集训DAY4】异或【字典树】
[Interface Test] Decoding the request body string of the requests library
【JZOF】32从上往下打印二叉树
函数习题(下)
一体化伺服电机在三轴钻孔机中的应用
用函数统计最长单词的字母数量
离散选择模型之Gumbel分布
中国SaaS企业排名,龙头企业Top10梳理
2022-08-09 mysql/stonedb-慢SQL-Q16分析
Force Buckle: 474. Ones and zeros
2022/8/9 考试总结
Filament-Material 绘制基本图形
直播间搭建,按钮左滑出现删除等操作按钮
关于服务治理
多线程是同时执行多个线程的吗