当前位置:网站首页>JS作用域链
JS作用域链
2022-07-13 17:35:00 【M78_国产007】
js对象有两种成员
一种是上文成员(js语法可以直接访问的成员)
一种是下文成员(底层语法访问的成员) [[scopes]]括起来的成员名 就是下文成员
[[scopes]]这个"对象"内部保存的就是函数的作用域
函数在定义/声明的时候 就有了[[scopes]] 里面保存了上层的AO对象
函数调用时生成AO对象 会把AO对象放在scopes
每次调用都会放在scopes顶部(理解为栈)
代码演示:
<script>
function a() {
var aaa = 123;
function b() {
var bbb = 234;
console.log(aaa);
}
return b;
}
var glob = 100;
var demo = a();
demo();
/*
作用域链解析:
Go:{a函数,glob:100,demo:b函数}
用数组来模拟作用域链,越底层在越后面
a.[[scopes]] ==>[AO(a):{aaa:123,b函数,},Go]
b.[[scopes]] ==>[AO(b),AO(a)] ==>[AO(b):{bbb:234,打印aaa},AO(a):{aaa:123,b函数,},Go]
打印aaa在作用域链中往下寻找,在我写这里就是往后寻找,打印123
*/
</script>边栏推荐
- 钱大妈基于 Flink 的实时风控实践
- Yandexbot IP address segment
- 解决IDEA2020连接MySQL8出现unable to load authentication plugin ‘caching_sha2_password‘异常
- The parameters trained by tensorflow are transformed into those under Caffe framework Caffemodel model
- 数组变化,但是无法更新视图(原因和思考)
- 系统总出故障怎么办,或许你该学学稳定性建设
- Idea automatically exports SQL statements of tables in the database
- Flink CDC MongoDB Connector 的实现原理和使用实践
- 2022 GopherChina 出品人及演讲内容陆续揭晓···
- 在线多行文本批量正则替换添加后缀工具
猜你喜欢
![[untitled]](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[untitled]

IE浏览器怎么查看cookie
Dark blue themed boss, can you add a typewriter function so that you can choose when typing

系统总出故障怎么办,或许你该学学稳定性建设

Flink CDC 在大健云仓的实践

2022 gopherchina's producers and speech content have been announced···

ES6--箭头函数

【无标题】

Software architecture diagram and mode introduction
![[a little knowledge] AQS](/img/17/9b5709ddf6a1212934ceb637ddd81b.png)
[a little knowledge] AQS
随机推荐
MVN clean or MVN clean package did not detect the test file
Basic related concepts of database
万建峰老师 干货分享2022年7月13日
一种可灰度的接口迁移方案
Ardunio——触摸传感器和灯光的互动——根据触摸屏判定是否亮灯
Six diseases of distributed monomers
yandex bot user agent
[interview: concurrent Article 12: multithreading: thread eight locks]
ECCV2022 | 腾讯优图29篇论文入选,含人脸安全、图像分割、目标检测等多个研究方向
Ardunio -- interaction between touch sensor and light -- judge whether the light is on according to the touch screen
CONDA based operation record of starting a tensorflow GPU (2.6.0) environment on win10 from scratch (2022.07)
Blue Bridge Cup: the second game of the 13th provincial competition of single chip microcomputer group
数据库的基本相关概念整理
mvn clean或mvn clean package没有检测到test文件
C语言字符和字符串
Why blog?
在线多行文本批量正则替换添加后缀工具
Mysql-MVCC
完整在pycharm上通过torch调用GPU(最细节)
初识c语言(二)