当前位置:网站首页>Closure implementation iterator effect
Closure implementation iterator effect
2022-07-01 09:18:00 【su27_ 0101】
iterator
Call a function repeatedly Will return different values But these values have some correlation For example, the number stored sequentially in the array
- Array iterator
var arr = [1,2,3,4,5];
var next = (function(){
var index = 0;
return function(){
if(index>=arr.length){
throw new Error(" Unable to continue iteration ");
}
return arr[index++];
}
})()
next();//1
1
next();
2
next();
3
next();
4
next();
5
next();
VM871:6 Uncaught Error: Unable to continue iteration
at <anonymous>:6:9
at <anonymous>:1:1
边栏推荐
- How to realize the usage of connecting multiple databases in idel
- Shell script - special variables: shell $, $*, [email protected], $$$
- 集成积木报表报错 org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常
- 【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云、小程序、Arduino的温湿度监控系统
- tensorrt yolov5_ trt. Py comments
- [pytorch learning] torch device
- R language observation log (part24) -- initialization settings
- Day06 branch structure and cycle (III)
- Can diffusion models be regarded as an autoencoder?
- Input标签的type设置为number,去掉上下箭头
猜你喜欢

2022.02.15_ Daily question leetcode six hundred and ninety

I use flask to write the website "one"

nacos簡易實現負載均衡

dsPIC30F6014a LCD 方块显示
![[pytorch] 2.4 convolution function nn conv2d](/img/eb/382a00af5f88d5954f10ea76343d6e.png)
[pytorch] 2.4 convolution function nn conv2d

Principles of Microcomputer - Introduction
![delete和delete[]引发的问题](/img/d9/a1c3e5ce51ef1be366a973aa42d1f0.png)
delete和delete[]引发的问题

Football and basketball game score live broadcast platform source code /app development and construction project

OSPF - virtual link details (including configuration commands)

【pytorch】nn. Crossentropyloss() and nn NLLLoss()
随机推荐
MapReduce编程基础
【pytorch学习】torch.device
pcl_viewer命令
Understanding and implementation of AVL tree
[pytorch] softmax function
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
An overview of the design of royalties and service fees of mainstream NFT market platforms
SDN_ Simple summary
Shell script - string
ES6-const本质与完全不可改实现(Object.freeze)
Latex插入的eps图片模糊解决方法
2.4 激活函数
2.2 【pytorch】torchvision.transforms
Input标签的type设置为number,去掉上下箭头
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
2.4 activation function
tensorrt yolov5_ trt. Py comments
微信小程序 webview 禁止页面滚动,同时又不影响业务内overflow的滚动的实现方式
2.2 【pytorch】torchvision. transforms
利用闭包实现私有变量