当前位置:网站首页>JS scope chain and closure
JS scope chain and closure
2022-07-01 09:18:00 【su27_ 0101】
On closures, let's talk about scope chains first
js Scope contains overall situation and function Scope (es5)
Such as :
var a = 'global var'
function fn(){
var b = 'function var';
var n = function(){
var c = 'inner function var'
}
}
c //; undefined
Use Venn's diagram to describe the current scope division 
Closures can be used to break through the scope chain
If you want to access the internal function in the global scope c Variable You need to use closures to connect it to the global scope
var a = 'global var'
function fn(){
var b = 'function var';
var n = function(){
var c = 'inner function var'
return c;
}
return n();
}
c = fn();
c;// 'inner function var'
Closure and GC
js gc use Reference count
In my submission Closures are used Reference count characteristic , bring Locally scoped variable references +1 Can't release
边栏推荐
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + MQ Series + nodejs local service + MySQL storage
- phpexcel 里 获取某一列的列表 获取某一列的字母
- 2.4 激活函数
- ES6-const本质与完全不可改实现(Object.freeze)
- PR training notes
- 小鸟识别APP
- Bird recognition app
- OSPF - virtual link details (including configuration commands)
- 【pytorch】2.4 卷积函数 nn.conv2d
- Yidian Yidong helps enterprises to efficiently manage equipment and improve equipment utilization
猜你喜欢

Simple load balancing with Nacos

OSPF - virtual link details (including configuration commands)

Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)

【检测技术课案】简易数显电子秤的设计与制作

Tree structure -- binary tree 2 non recursive traversal

I use flask to write the website "one"

nacos简易实现负载均衡

队列的实现和应用

【pytorch】nn. Crossentropyloss() and nn NLLLoss()

Jetson nano installs tensorflow GPU and problem solving
随机推荐
Understanding and implementation of AVL tree
js作用域链与闭包
2.2 【pytorch】torchvision.transforms
js this丢失问题分析 及 解决方案
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
Youqitong PE toolbox [vip] v3.7.2022.0106 official January 22 Edition
美团2022年机试
Mysql 优化
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
微信小程序 webview 禁止页面滚动,同时又不影响业务内overflow的滚动的实现方式
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云和Arduino的化学环境系统检测,支持钉钉机器人告警
韦东山板子编译内核问题解决
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
SDN_简单总结
Football and basketball game score live broadcast platform source code /app development and construction project
2.4 activation function
Shell script -select in loop
樹結構---二叉樹2非遞歸遍曆
Class loading
phpexcel 里 获取某一列的列表 获取某一列的字母