当前位置:网站首页>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 }
}
};
}
边栏推荐
- jmeter性能测试步骤实战教程
- TypeScript void 基础类型
- navicat如何导入MySQL脚本
- Significance and measures of encryption protection for intelligent terminal equipment
- Ble of Jerry [chapter]
- Twelve rules for naming variables
- Google可能在春节后回归中国市场。
- JMeter performance test steps practical tutorial
- [MySQL learning notes 32] mvcc
- 合规、高效,加快药企数字化转型,全新打造药企文档资源中心
猜你喜欢
随机推荐
Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
Google may return to the Chinese market after the Spring Festival.
Simple and understandable high-precision addition in C language
Solution to the problem of breakthrough in OWASP juice shop shooting range
Apache middleware vulnerability recurrence
word删除括号里内容
edge浏览器 路径获得
Luogu p4127 [ahoi2009] similar distribution problem solution
word中如何删除某符号前面或后面所有的文字
C语言 简单易懂的高精度加法
Markdown 中设置图片图注
Key value judgment in the cycle of TS type gymnastics, as keyword use
数字经济时代,如何保障安全?
The difference between TS Gymnastics (cross operation) and interface inheritance
The way to learn go (II) basic types, variables and constants
[CF Gym101196-I] Waif Until Dark 网络最大流
TypeScript 变量作用域
C - Inheritance - hidden method
[dictionary tree] [trie] p3879 [tjoi2010] reading comprehension
Fundamentals of C language 9: Functions