当前位置:网站首页>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
边栏推荐
- 哈希(Hash)竞猜游戏系统开发功能分析及源码
- Hash哈希竞猜游戏系统开发如何开发丨哈希竞猜游戏系统开发(多套案例)
- What is the development of block hash quiz game system? Hash quiz game system development (case mature)
- Jiuqi ny8b062d MCU specification /datasheet
- What is the application technology of neural network and Internet of things
- idea大小写快捷键
- 【ISMB2022教程】图表示学习的精准医疗,哈佛大学Marinka Zitnik主讲,附87页ppt
- Function analysis and source code of hash guessing game system development
- Flet教程之 08 AppBar工具栏基础入门(教程含源码)
- word中使用自动插入题注功能
猜你喜欢
【历史上的今天】7 月 4 日:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生
#夏日挑战赛#带你玩转HarmonyOS多端钢琴演奏
Win11U盘拒绝访问怎么办?Win11U盘拒绝访问的有效解决方法
电脑共享打印机拒绝访问要怎么办
Reinforcement learning - learning notes 2 | value learning
NLP、视觉、芯片...AI重点方向发展几何?青源会展望报告发布[附下载]
Flet教程之 05 OutlinedButton基础入门(教程含源码)
AP8022开关电源小家电ACDC芯片离线式开关电源IC
What if the computer page cannot be full screen? The solution of win11 page cannot be full screen
How to solve the problem that win11 cannot write the value to the registry key?
随机推荐
Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)
Qt五子棋人机对战画棋子之QPainter的使用误区总结
Win11共享文件打不开怎么办?Win11共享文件打不开的解决方法
被奉为经典的「金字塔原理」,教给我们哪些PPT写作技巧?
How does the computer save web pages to the desktop for use
BFC面试简述
华为云云商店首页 Banner 资源位申请
Regular replacement [JS, regular expression]
针对深度学习的“失忆症”,科学家提出基于相似性加权交错学习,登上PNAS
So this is the BGP agreement
Is it necessary to apply for code signing certificate for software client digital signature?
Lingyun going to sea | Murong Technology & Huawei cloud: creating a model of financial SaaS solutions in Africa
记录线上bug解决list(未完待续7/4)
mysql语句执行详解
What if the computer page cannot be full screen? The solution of win11 page cannot be full screen
Practical examples of node strong cache and negotiation cache
Lingyun going to sea | Wenhua online & Huawei cloud: creating a new solution for smart teaching in Africa
js 闭包
Understand the reading, writing and creation of files in go language
Practice examples to understand JS strong cache negotiation cache