当前位置:网站首页>JS中对作用域链的理解(查找变量)
JS中对作用域链的理解(查找变量)
2022-08-02 00:14:00 【weixin_46051260】
作用域:变量和函数生效的区域
1)全局作用域:任何不在函数中或者大括号中声明的变量,都是在全局作用域下
全局作用域下的声明的变量可以在程序中任何位置访问
2)函数作用域:函数作用域中定义的变量,只能在函数内部访问,不能在函数外部访问
3)块级作用域:let和const定义的变量在大括号外面不可以被访问
作用域链
js使用一个变量,首先js引擎会在当前作用域下查找
如果没有找到,去上层作用域寻找,以此类推,知道找到变量或者到达全局作用域,如果没有找到,直接报错或者隐式声明
边栏推荐
- TCL: Pin Constraints Using the tcl Scripting Language in Quartus
- 【HCIP】BGP小型实验(联邦,优化)
- The Statement update Statement execution
- Mean Consistency Tracking of Time-Varying Reference Inputs for Multi-Agent Systems with Communication Delays
- Collection of NFT tools
- GIF making - very simple one-click animation tool
- BGP first experiment
- JSP out.print()和out.write()方法的不同之处
- Play NFT summer: this collection of tools is worth collecting
- go笔记记录——channel
猜你喜欢

Redis-消息发布订阅

bgp 聚合 反射器 联邦实验

众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散

An overview of the most useful DeFi tools

Are test points the same as test cases?

Microsoft PC Manager V2.1 beta version officially released

不要用jOOQ串联字符串

一文概览最实用的 DeFi 工具

Disk and file system management

Don't know about SynchronousQueue?So ArrayBlockingQueue and LinkedBlockingQueue don't and don't know?
随机推荐
PHP从txt文件中读取数据的方法
扑克牌问题
Looking back at 5 recessionary times in history: How might this time be different?
Kunpeng compile and debug plug-in actual combat
Angr(十二)——官方文档(Part3)
协作乐高 All In One:DAO工具大全
Microsoft PC Manager V2.1 beta version officially released
鲲鹏编译调试插件实战
这 4 款电脑记事本软件,得试试
2022/08/01 Study Notes (day21) Generics and Enums
Double queue implementation stack?Dual stack implementation queue?
一文概览最实用的 DeFi 工具
nodeJs--mime module
具有通信时延的多自主体系统时变参考输入的平均一致性跟踪
玩转NFT夏季:这份工具宝典值得收藏
基于数据驱动的变电站巡检机器人自抗扰控制
基于编码策略的电网假数据注入攻击检测
构造方法,this关键字,方法的重载,局部变量与成员变量
JSP built-in object out object function introduction
Play NFT summer: this collection of tools is worth collecting