当前位置:网站首页>Variable promotion and function promotion in JS
Variable promotion and function promotion in JS
2022-07-04 13:58:00 【51CTO】
js Variable promotion and function promotion in
The first value printed is undefined, The second printed value is yyyyy.
The actual method internal code execution order should be like this :
When you see the execution order of the split code, you are not confused about the results .
Why is there a variable increase
So why is there a phenomenon of variable Promotion ?
Actually js Like any other language , You have to go through the compilation and execution phases . and js During the compilation phase , All variable declarations will be collected and declared in advance , Other statements do not change their order , therefore , During the compilation phase , The first step has been carried out , The second step is to execute the statement at the execution stage .
summary
1.js Will promote the declaration of variables to js Top execution , So for this statement :var a = 2; Actually js It will be divided into var a; and a = 2; Two parts , And will var a This step is lifted to the top to perform .
2. The essence of variable promotion is actually due to js When the engine compiles , All variables are declared , So when executing , All variables have been declared .
3. When multiple variables with the same name are declared , Function declarations override other declarations . If there are multiple function declarations , The last function declaration overrides all previous declarations .
边栏推荐
- One of the solutions for unity not recognizing riders
- unity不识别rider的其中一种解决方法
- js中的变量提升和函数提升
- Read the BGP agreement in 6 minutes.
- Introduction to XML III
- CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021
- Don't turn down, three sentences to clarify the origin of cross domain resource request errors
- 30:第三章:开发通行证服务:13:开发【更改/完善用户信息,接口】;(使用***BO类承接参数,并使用了参数校验)
- JVM series - stack and heap, method area day1-2
- Runc hang causes the kubernetes node notready
猜你喜欢
面试官:Redis中哈希数据类型的内部实现方式是什么?
Source code compilation and installation of MySQL
Database lock table? Don't panic, this article teaches you how to solve it
【R语言数据科学】:交叉验证再回首
上汽大通MAXUS正式发布全新品牌“MIFA”,旗舰产品MIFA 9正式亮相!
Detailed explanation of Fisher information quantity detection countermeasure sample code
8 expansion sub packages! Recbole launches 2.0!
CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...
The only core indicator of high-quality software architecture
.Net之延迟队列
随机推荐
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
Introduction to XML II
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
易周金融 | Q1保险行业活跃人数8688.67万人 19家支付机构牌照被注销
分布式BASE理论
2022危险化学品经营单位主要负责人练习题及模拟考试
Runc hang causes the kubernetes node notready
Doctoral application | West Lake University Learning and reasoning system laboratory recruits postdoctoral / doctoral / research internship, etc
好博医疗冲刺科创板:年营收2.6亿 万永钢和沈智群为实控人
8 expansion sub packages! Recbole launches 2.0!
C语言程序设计选题参考
Automatic filling of database public fields
Go 语言入门很简单:Go 实现凯撒密码
#yyds干货盘点# 解决名企真题:连续最大和
Flet tutorial 03 basic introduction to filledbutton (tutorial includes source code) (tutorial includes source code)
提高MySQL深分页查询效率的三种方案
Fs7867s is a voltage detection chip used for power supply voltage monitoring of digital system
WPF double slider control and forced capture of mouse event focus
2022G3锅炉水处理考试题模拟考试题库及模拟考试
一次 Keepalived 高可用的事故,让我重学了一遍它