当前位置:网站首页>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
边栏推荐
- Length of the longest integrable subarray
- 软件客户端数字签名一定要申请代码签名证书吗?
- How does the computer save web pages to the desktop for use
- Après l'insertion de l'image dans le mot, il y a une ligne vide au - dessus de l'image, et la disposition est désordonnée après la suppression
- CDGA|数据治理不得不坚持的六个原则
- 科普达人丨一文看懂阿里云的秘密武器“神龙架构”
- How does win11 search for wireless displays? Win11 method of finding wireless display device
- 电脑共享打印机拒绝访问要怎么办
- FS8B711S14电动红酒开瓶器单片机IC方案开发专用集成IC
- 剑指 Offer II 80-100(持续更新)
猜你喜欢
Understand the reading, writing and creation of files in go language

Qt编写物联网管理平台38-多种数据库支持

What is involution?

NetCore3.1 Json web token 中间件

Qt五子棋人机对战画棋子之QPainter的使用误区总结

How does win11 search for wireless displays? Win11 method of finding wireless display device

Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation

What if the WiFi of win11 system always drops? Solution of WiFi total drop in win11 system

电脑共享打印机拒绝访问要怎么办

Flet教程之 06 TextButton基础入门(教程含源码)
随机推荐
二叉树的四种遍历方式以及中序后序、前序中序、前序后序、层序创建二叉树【专为力扣刷题而打造】
What financial products can you buy with a deposit of 100000 yuan?
LeetCode 871. Minimum refueling times
Flet教程之 08 AppBar工具栏基础入门(教程含源码)
Flet教程之 05 OutlinedButton基础入门(教程含源码)
一文搞懂Go语言中文件的读写与创建
字节测试工程师十年经验直击UI 自动化测试痛点
Win11系统wifi总掉线怎么办?Win11系统wifi总掉线的解决方法
Huawei cloud store homepage banner resource bit application
Flet tutorial 06 basic introduction to textbutton (tutorial includes source code)
【深度学习】一文看尽Pytorch之十九种损失函数
Win11共享文件打不开怎么办?Win11共享文件打不开的解决方法
Win11怎么搜索无线显示器?Win11查找无线显示器设备的方法
go笔记(1)go语言介绍以及特点
In operation (i.e. included in) usage of SSRs filter
1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效
阿里测试师用UI自动化测试实现元素定位
凌云出海记 | 文华在线&华为云:打造非洲智慧教学新方案
Flet tutorial 04 basic introduction to filledtonalbutton (tutorial includes source code)
Practical examples of node strong cache and negotiation cache