当前位置:网站首页>JS closure
JS closure
2022-07-04 20:44:00 【Big chicken legs are best】
Simply speaking , That is, the internal function can read the variables of the external function , And these variables will be saved in memory , It will not be automatically cleared after the outer function is called
advantage
Variables are stored in memory for a long time , Avoid the pollution of global variables , Mimic block level scope
for(var i=0;i<5;i++){
(function f(i){
let t=i
setTimeout(()=>{
console.log(i)
})
})(i)
}
shortcoming
memory-resident , Will increase memory usage , Improper use will cause memory leakage
边栏推荐
- tcp为啥是三次握手和四次挥手
- ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
- Talking about cookies of client storage technology
- FS4061A升压8.4V充电IC芯片和FS4061B升压12.6V充电IC芯片规格书datasheet
- In operation (i.e. included in) usage of SSRs filter
- Reinforcement learning - learning notes 2 | value learning
- go语言笔记(2)go一些简单运用
- What is involution?
- Flet教程之 04 FilledTonalButton基础入门(教程含源码)
- So this is the BGP agreement
猜你喜欢
托管式服务网络:云原生时代的应用体系架构进化
【历史上的今天】7 月 4 日:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生
NLP、视觉、芯片...AI重点方向发展几何?青源会展望报告发布[附下载]
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born
So this is the BGP agreement
[ismb2022 tutorial] the picture shows the precision medicine of learning. Marinka zitnik, Harvard University, keynote speaker, with 87 ppt
Fleet tutorial 08 introduction to AppBar toolbar Basics (tutorial includes source code)
《动手学深度学习》(三) -- 卷积神经网络 CNN
Flet教程之 04 FilledTonalButton基础入门(教程含源码)
Flet教程之 06 TextButton基础入门(教程含源码)
随机推荐
强化学习-学习笔记2 | 价值学习
Lingyun going to sea | 10 jump &huawei cloud: jointly help Africa's inclusive financial services
Employment prospects of neural network Internet of things application technology [welcome to add]
GVM使用
ICML 2022 | Meta提出鲁棒的多目标贝叶斯优化方法,有效应对输入噪声
So this is the BGP agreement
What if the WiFi of win11 system always drops? Solution of WiFi total drop in win11 system
idea恢复默认快捷键
mysql语句执行详解
同事的接口文档我每次看着就头大,毛病多多。。。
Alibaba testers use UI automated testing to achieve element positioning
go语言笔记(4)go常用管理命令
Flet教程之 07 PopupMenuButton基础入门(教程含源码)
六石编程学:关于代码,有六个得意
Why is the maximum speed the speed of light
记录线上bug解决list(未完待续7/4)
Win11系统wifi总掉线怎么办?Win11系统wifi总掉线的解决方法
《动手学深度学习》(三) -- 卷积神经网络 CNN
Lingyun going to sea | Wenhua online & Huawei cloud: creating a new solution for smart teaching in Africa
哈希(Hash)竞猜游戏系统开发功能分析及源码