当前位置:网站首页>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
边栏推荐
- OSPF - virtual link details (including configuration commands)
- 【检测技术课案】简易数显电子秤的设计与制作
- Shell script case in statement
- MySQL optimization
- 序列化、监听、自定义注解
- 2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据
- js作用域链与闭包
- phpexcel 里 获取某一列的列表 获取某一列的字母
- Which method is good for the management of fixed assets of small and medium-sized enterprises?
- [ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
猜你喜欢
![2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder](/img/19/cce8d8a7cdcb1021166c46adf803c1.png)
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder

Structure de l'arbre - - - arbre binaire 2 traversée non récursive

Principles of Microcomputer - internal and external structure of microprocessor

樹結構---二叉樹2非遞歸遍曆

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

Preparing for the Blue Bridge Cup -- bit operation

Phishing identification app

2.4 激活函数

【pytorch】softmax函数

【pytorch】nn. Crossentropyloss() and nn NLLLoss()
随机推荐
JCL and slf4j
2.4 激活函数
How to launch circle of friends marketing and wechat group activities
类加载
LogBack
Jeecg restart alarm 40001
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
The fixed assets management system enables enterprises to dynamically master assets
Shell script -for loop and for int loop
Installation and use of NoSQL database
Leetcode daily question brushing record --540 A single element in an ordered array
nacos簡易實現負載均衡
Shell script case in and regular expressions
js作用域链与闭包
Learning practice: comprehensive application of cycle and branch structure (II)
Pain points and solutions of fixed assets management of group companies
es6-顶层对象与window的脱钩
2.2 【pytorch】torchvision. transforms
Key points of NFT supervision and overseas policies
微信小程序 webview 禁止页面滚动,同时又不影响业务内overflow的滚动的实现方式