当前位置:网站首页>Symbol. Iterator iterator
Symbol. Iterator iterator
2022-06-24 09:50:00 【Time202051】
iterator Role is : Deconstruction of traversal data is not supported " Ergodic "
let courses = {
allCourse: {
frontend: ["ES", " Applet ", "Vue"],
backend: ["java", "Python"],
webapp: ["android", "IOS"],
},
};
courses[Symbol.iterator] = function () {
let allCourse = this.allCourse;
let itemKey = Object.keys(allCourse);
let values = [];
return {
next() {
if (!values.length) {
if (itemKey.length) {
values = allCourse[itemKey[0]];
itemKey.shift();
}
}
return {
done: !values.length,
value: values.shift(),
};
},
};
};
for (let item of courses) {
console.log(item);
}
// Print the content
/*ES Applet Vue java Python android IOS*/
Get we can get the array traversal separately and then splice . But if the project is used more , I have to go through logic every time . So add iterators directly . This is direct for of You can traverse it directly
边栏推荐
猜你喜欢

顶刊TPAMI 2022!基于不同数据模态的行为识别:最新综述

indexedDB本地存储,首页优化

Servlet快速筑基

Oracle数据文件头SCN不一致处理方法

关于thinkphp5 使用模型save()更新数据提示 method not exist:think\db\Query-> 报错解决方案

PTA monkey chooses King (Joseph Ring problem)

Grpc local test joint debugging tool bloomrpc

Top issue tpami 2022! Behavior recognition based on different data modes: a recent review

使用Live Chat促進業務銷售的驚人技巧

如何解决独立站多渠道客户沟通难题?这款跨境电商插件一定要知道!
随机推荐
PTA monkey chooses King (Joseph Ring problem)
带文字的seekbar : 自定义progressDrawable/thumb :解决显示不全
June 13-19, 2022 AI industry weekly (issue 102): career development
Endgame P.O.O
JCIM|药物发现中基于AI的蛋白质结构预测:影响和挑战
ThinkPHP5多语言切换项目实战
LeetCode: 137. 只出现一次的数字 II
An open source monitoring data collector that can monitor everything
Learning Tai Chi Maker - esp8226 (XIII) OTA
数字化转型的失败原因及成功之道
Use of vim
谈谈数字化转型晓知识
In depth analysis of Apache bookkeeper series: Part 3 - reading principle
5分钟,客服聊天处理技巧,炉火纯青
文献调研报告
PostgreSQL
英伟达这篇CVPR 2022 Oral火了!2D图像秒变逼真3D物体!虚拟爵士乐队来了!
Idea cannot save settings source root d:xxxx is duplicated in module XXX
二十、处理器调度(RR时间片轮转,MLFQ多级反馈队列,CFS完全公平调度器,优先级翻转;多处理器调度)
Amazing tips for using live chat to drive business sales