当前位置:网站首页>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 }
}
};
}
边栏推荐
- TypeScript 变量作用域
- Ble of Jerry [chapter]
- 数字IC设计笔试题汇总(一)
- Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
- navicat如何导入MySQL脚本
- 位运算异或
- Is the super browser a fingerprint browser? How to choose a good super browser?
- Related operations of Excel
- The difference between TS Gymnastics (cross operation) and interface inheritance
- SSM learning
猜你喜欢

Fundamentals of C language 9: Functions

mysql如何合并数据

opencv学习笔记八--答题卡识别

杰理之BLE【篇】

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

杰理之BLE【篇】

Set picture annotation in markdown

Oracle column to row -- a field is converted to multiple rows according to the specified separator

Sharing of source code anti disclosure scheme under burning scenario

杰理之BLE【篇】
随机推荐
TypeScript 变量作用域
超级浏览器是指纹浏览器吗?怎样选择一款好的超级浏览器?
杰理之开发板上电开机,就可以手机打开 NRF 的 APP【篇】
When the Jericho development board is powered on, you can open the NRF app with your mobile phone [article]
edge瀏覽器 路徑獲得
Is the super browser a fingerprint browser? How to choose a good super browser?
chrome查看页面fps
Google可能在春节后回归中国市场。
word中如何删除某符号前面或后面所有的文字
位运算异或
TS 类型体操 之 循环中的键值判断,as 关键字使用
OpenJudge NOI 2.1 1661:Bomb Game
C # create database connection object SQLite database
Typescript variable scope
Wonderful use of TS type gymnastics string
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
datax自检报错 /datax/plugin/reader/._drdsreader/plugin.json]不存在
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
mysql如何合并数据