当前位置:网站首页>什么是作用域和作用域链
什么是作用域和作用域链
2022-07-29 01:23:00 【没有天赋全靠手打】
什么是作用域和作用域链
作用域
对象可以被调用的区域,定义一个变量,变量有效的作用域
a(){
let str = '1';
let fun1 = function(){
let str2 = '2';
console.log(str,str2); // 1 2
}
console.log(str);// 1
console.log(str2); // str2 is not defined
}
上诉 str 的作用域是 a() 内部, str2 是 fun1() 内部
作用域链
调用某个函数或属性时,先在当前作用域寻找,如果找不到则向上父级寻找,直到找到全局作用域为止,这个链式查找 的过程,就是作用域链。
边栏推荐
- StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?
- 给LaTeX公式添加优美的注解;日更『数据科学』面试题集锦;大学生『计算机』自学指南;个人防火墙;前沿资料/论文 | ShowMeAI资讯日报
- Basic working principle and LTSpice simulation of 6T SRAM
- Regular filtering data learning notes (①)
- The solution of reducing the sharpness of pictures after inserting into word documents
- Using local cache + global cache to realize user rights management of small systems
- 【流放之路-第四章】
- 数学建模——红酒品质分类
- [the road of Exile - Chapter 5]
- 12.< tag-动态规划和子序列, 子数组>lt.72. 编辑距离
猜你喜欢

【流放之路-第四章】

Dynamic memory and smart pointer

Stonedb invites you to participate in the open source community monthly meeting!

【公开课预告】:快手GPU/FPGA/ASIC异构平台的应用探索

Planning mathematics final exam simulation II
![[the road of Exile - Chapter 7]](/img/3c/8b4b7c40367b8b68d0361d9ca4013a.png)
[the road of Exile - Chapter 7]

Talk about possible problems when using transactions (@transactional)

九天后我们一起,聚焦音视频、探秘技术新发展
![[the road of Exile - Chapter 6]](/img/cd/408118f43dbda2e6367b328a1c20fc.png)
[the road of Exile - Chapter 6]

(CVPR-2019)选择性的内核网络
随机推荐
Mobile communication -- simulation model of error control system based on convolutional code
弹性布局 单选
[7.27] code source - [deletion], [bracket sequence], [number replacement], [game], [painting]
(arxiv-2018) reexamine the time modeling of person Reid based on video
[golang] use select {}
Lm13 morphological quantification momentum period analysis
Leetcode 112: path sum
Mathematical modeling -- heat conduction of subgrade on Permafrost
Understand the clock tree in STM32 in simple terms
Sigma-DSP-OUTPUT
[7.21-26] code source - [good sequence] [social circle] [namonamo]
Web crawler API Quick Start Guide
Covering access to 2w+ traffic monitoring equipment, EMQ creates a new engine for the digitalization of all elements of traffic in Shenzhen
[circuit design] open collector OC output of triode
Promise solves asynchrony
[the road of Exile - Chapter 4]
JS timer setinterval clearinterval delayer setTimeout asynchronous animation
[netding cup 2020 rosefinch group]nmap
【流放之路-第四章】
[the road of Exile - Chapter 6]