当前位置:网站首页>JS advanced - lexical scope
JS advanced - lexical scope
2022-07-22 19:29:00 【Please call me Gerald 6】
Scope classification :
1. Static scope ( Lexical scope ):Javascript
2. Dynamic scope :bash
Characteristic contrast :
1. The lexical scope is determined when the code is defined , Instead of looking at the call
2. Dynamic scope is determined during code execution
var a = 10;
function fun(){
console.log(a);
};
function fun2(){
var a = 20;
fun();
};
fun2();// Output 10
fun();// Output 10
Because of the function fun and fun2 Are defined in the global environment , So their upper scope is the global scope Global, and Global It holds variables a=10, So when fun() Calls and fun2() When calling , Look for yourself first , If you can't find it, go to the overall situation ! So they all output 10, That is to say, the lexical scope has been determined when the code is defined , Instead of looking at function calls
边栏推荐
- Rongyun x Xingzhi: exclusive Post-00 self social plot (including lottery)
- MIHA tour recruited a large number of new students, and the school enrollment was approved in advance on the last day!
- Mysql5.7 decompression configuration steps
- Grafana panel - override field values
- JUC synchronizer
- Oracle容器数据库的安装和使用
- Leetcode daily question 2022/2/7-2022/2/13
- Flutter's first program Hello world!
- 字符集和字符编码
- LeetCode 每日一题 2022/3/7-2022/3/13
猜你喜欢
Scenario practice | how to use rongyun super group to build a game community
About human resource outsourcing companies
Swagger UI introduction and common notes
场景实践 | 如何使用融云超级群构建游戏社区
No longer clinging to products, apple cook increased the investment in American antitrust Lobbying: it spent $4.6 million in the first half of this year
Several trends in the future development of software industry
2022版Centos8 yum镜像安装&阿里云安装Mysql 5.7教程与问题解决
Industrial router oilfield wireless monitoring
grafana面板-关于转换
This points to the problem
随机推荐
Numpy finding the mean value of non-zero elements of matrix
Leetcode daily question 2021/12/13-2021/12/19
Flutter 第一個程序Hello World!
字符集和字符编码
Leetcode daily question 2022/3/28-2022/4/3
Shell script debugging technology
Flutter 第一个程序Hello World!
Behind the explosion of collaborative office market: cloud communication capability is the focus of demand
为什么重写equels方法一定要重写hashCode方法
Constructor
十年架构五年生活-05第一次出差
融云漫话:通信中台
Writing word accumulation
2、 Idea build jfinal project + automatic code generation + database operation test (three ways)
融云办政事: “小网格”也能实现“大治理”
MFC dialog program only runs a simple example of a single instance
Leetcode daily question 2022/2/28-2022/3/6
[FatFs] porting FatFs file system based on STM32 SD card
工业路由器油田无线监控
Rongyun x Xingzhi: exclusive Post-00 self social plot (including lottery)