当前位置:网站首页>JS中对作用域链的理解(查找变量)
JS中对作用域链的理解(查找变量)
2022-08-02 00:14:00 【weixin_46051260】
作用域:变量和函数生效的区域
1)全局作用域:任何不在函数中或者大括号中声明的变量,都是在全局作用域下
全局作用域下的声明的变量可以在程序中任何位置访问
2)函数作用域:函数作用域中定义的变量,只能在函数内部访问,不能在函数外部访问
3)块级作用域:let和const定义的变量在大括号外面不可以被访问
作用域链
js使用一个变量,首先js引擎会在当前作用域下查找
如果没有找到,去上层作用域寻找,以此类推,知道找到变量或者到达全局作用域,如果没有找到,直接报错或者隐式声明
边栏推荐
- Interview high-frequency test questions solution - stack push and pop sequence, effective parentheses, reverse Polish expression evaluation
- Short video seo search optimization main content
- JSP page指令errorPage属性起什么作用呢?
- go语言标准库fmt包怎么使用
- Simpson's paradox
- IO流基础
- These 4 computer notepad software, you have to try
- BGP 第一次实验
- Redis - message publish and subscribe
- PHP to read data from TXT file
猜你喜欢

Microsoft PC Manager V2.1 beta version officially released

已知中序遍历数组和先序遍历数组,返回后序遗历数组

Short video SEO search operation customer acquisition system function introduction

GIF making - very simple one-click animation tool

Arduino Basic Syntax

Are test points the same as test cases?

Kunpeng compile and debug plug-in actual combat

Automatic conversion of Oracle-style implicit joins to ANSI JOINs using jOOQ

How to design a circular queue?Come and learn~

22. The support vector machine (SVM), gaussian kernel function
随机推荐
Are test points the same as test cases?
Kotlin协程:创建、启动、挂起、恢复
JSP how to obtain the path information in the request object?
Pytorch seq2seq 模型架构实现英译法任务
什么是低代码(Low-Code)?低代码适用于哪些场景?
632. 最小区间
Business test how to avoid missing?
JSP page指令errorPage属性起什么作用呢?
当奈飞的NFT忘记了Web2的业务安全
具有通信时延的多自主体系统时变参考输入的平均一致性跟踪
06-SDRAM : SDRAM control module
辨析内存函数memset、memcmp、memmove以及memcpy
An overview of the most useful DeFi tools
渗透测试与攻防对抗——渗透测试基础
Kunpeng compile and debug plug-in actual combat
JSP out.println()方法具有什么功能呢?
Double queue implementation stack?Dual stack implementation queue?
nodeJs--mime模块
swing的Jlist列表滚动条以及增加元素的问题
CRS management and maintenance