当前位置:网站首页>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
边栏推荐
- 长城证券开户安全吗 股票开户流程网上开户
- B2B mall system development of electronic components: an example of enabling enterprises to build standardized purchase, sale and inventory processes
- 漫谈客户端存储技术之Cookie篇
- node强缓存和协商缓存实战示例
- Redis分布式锁的实现
- 最长的可整合子数组的长度
- Fleet tutorial 08 introduction to AppBar toolbar Basics (tutorial includes source code)
- What if win11u disk refuses access? An effective solution to win11u disk access denial
- Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)
- 什么是区块哈希竞猜游戏系统开发?哈希竞猜游戏系统开发(案例成熟)
猜你喜欢
Fleet tutorial 08 introduction to AppBar toolbar Basics (tutorial includes source code)
Qt五子棋人机对战画棋子之QPainter的使用误区总结
ICML 2022 | meta proposes a robust multi-objective Bayesian optimization method to effectively deal with input noise
Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)
What if the computer page cannot be full screen? The solution of win11 page cannot be full screen
Reinforcement learning - learning notes 2 | value learning
精选综述 | 用于白内障分级/分类的机器学习技术
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born
Employment prospects of neural network Internet of things application technology [welcome to add]
Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...
随机推荐
C server log module
Flet tutorial 07 basic introduction to popupmenubutton (tutorial includes source code)
[Beijing Xunwei] i.mx6ull development board porting Debian file system
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
tcp为啥是三次握手和四次挥手
idea插件
如何让你的小游戏适配不同尺寸的手机屏幕
Employment prospects of neural network Internet of things application technology [welcome to add]
What financial products can you buy with a deposit of 100000 yuan?
阿里测试师用UI自动化测试实现元素定位
【深度学习】一文看尽Pytorch之十九种损失函数
Why is the maximum speed the speed of light
idea恢复默认快捷键
长城证券开户安全吗 股票开户流程网上开户
Managed service network: application architecture evolution in the cloud native Era
SSRS筛选器的IN运算(即包含于)用法
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born
强化学习-学习笔记2 | 价值学习
Form组件常用校验规则-1(持续更新中~)
Detailed explanation of Audi EDI invoice message