当前位置:网站首页>Iterator Foundation
Iterator Foundation
2022-07-06 07:33:00 【Romantic bearded boy】
ES6 Before , The only data structures used to represent a group of data are arrays and objects .
const array = [1, 2, 3, 4];
const object = {
a: 1,
b: 2,
c: 3
}
ES6 in , added Set and Map Two data structures .
One 、 Code case
var it = makeIterator(['a', 'b']);
it.next() // { value: "a", done: false }
it.next() // { value: "b", done: false }
it.next() // { value: undefined, done: true }
function makeIterator(array) {
var nextIndex = 0;
return {
next: function() {
if(nextIndex < array.length) {
return {
value: array[nextIndex++], done: false }
}
return {
value: undefined, done: true }
}
};
}
边栏推荐
- Games101 Lesson 7 shading 1 Notes
- 杰理之需要修改 gatt 的 profile 定义【篇】
- TS 类型体操 之 extends,Equal,Alike 使用场景和实现对比
- Structure summary of SystemVerilog integrable model
- word中把帶有某個符號的行全部選中,更改為標題
- js对象获取属性的方法(.和[]方式)
- Basics of reptile - Scratch reptile
- Typescript interface properties
- Luogu p4127 [ahoi2009] similar distribution problem solution
- word中把带有某个符号的行全部选中,更改为标题
猜你喜欢
杰理之BLE【篇】
word中如何删除某符号前面或后面所有的文字
Typescript interface and the use of generics
[online problem processing] how to kill the corresponding process when the MySQL table deadlock is caused by the code
[MySQL learning notes 30] lock (non tutorial)
[MySQL learning notes 32] mvcc
How to delete all the words before or after a symbol in word
Bugku CTF daily question: do you want seeds? Blackmailed
Redis builds clusters
datax自检报错 /datax/plugin/reader/._drdsreader/plugin.json]不存在
随机推荐
The differences and advantages and disadvantages between cookies, seeion and token
How MySQL merges data
Seriously recommend several machine learning official account
How can word delete English only and keep Chinese or delete Chinese and keep English
Relevant introduction of clip image
Openjudge noi 2.1 1749: Digital Square
杰理之BLE【篇】
烧录场景下的源代码防泄密方案分享
JMeter performance test steps practical tutorial
Typescript interface and the use of generics
Redis builds clusters
位运算异或
Typescript interface properties
Force buckle day31
NiO programming introduction
How to delete all the words before or after a symbol in word
Scala语言学习-08-抽象类
【线上问题处理】因代码造成mysql表死锁的问题,如何杀掉对应的进程
Go learning --- use reflection to judge whether the value is valid
Apache middleware vulnerability recurrence