当前位置:网站首页>Pre parsing of JS
Pre parsing of JS
2022-04-23 09:22:00 【Small white egg tart】
Catalog
One 、js The engine executes the code in two steps : Pre parsing and code execution
One 、js The engine executes the code in two steps : Pre parsing and code execution
1. Pre parsing will js Everything in it var,function Raise the declaration of to the front of the current scope
2. Code execution , Execute from top to bottom in code order
Two 、 Pre parsing is divided into variable pre parsing ( Variable Promotion ) And function pre parsing ( Function enhancement )
1. Variable Promotion
Is to promote all variable declarations to the front of the current scope , But the assignment operation is not promoted .
2. Function enhancement
To go to the front of the current function declaration is to elevate all the scope , But don't call the function .
3、 ... and 、 Case study
console.log(num1);
var num1 = 12;
// amount to
// var num1;
// console.log(num1);
// num1=12;
So the output undefined
fn();
function fn() {
var a = 20;
console.log(a);
}
// amount to
// function fn() {
// var a = 20;
// console.log(a);
// }
// fn();
It can output normally 20
fn1();
var fn1 = function() {
console.log(22);
}
Function expression The call must be written below the function expression

版权声明
本文为[Small white egg tart]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230624114276.html
边栏推荐
- Chapter VIII project stakeholder management of information system project manager summary
- Thread scheduling (priority)
- 653. Sum of two IV - input BST
- Group Backpack
- npm报错 :operation not permitted, mkdir ‘C: \Program Files \node js \node_ cache _ cacache’
- RSA 加密解密签名验签
- 数据清洗 ETL 工具Kettle的安装
- Is Zhongyan futures safe and reliable?
- [Luke V0] verification environment 2 - Verification Environment components
- How to protect open source projects from supply chain attacks - Security Design (1)
猜你喜欢

Kettle实验 (三)

Machine learning (VI) -- Bayesian classifier

资源打包关系依赖树

Arbre de dépendance de l'emballage des ressources

Matlab draw five-star red flag

Enter "net start MySQL" and "system error 5. Access denied" appears. Detailed explanation of the problem

Brush classic topics

Summary of wrong questions 1

AQS & reentrantlock implementation principle

STM32 and FreeRTOS stack parsing
随机推荐
GUI, CLI and UNIX Philosophy
NLLLoss+log_ SoftMax=CE_ Loss
Kettle实验 转换案例
[reading notes] Chapter 5 conditional statements, circular statements and block statements of Verilog digital system design tutorial (with answers to thinking questions)
DJ music management software pioneer DJ rekordbox
tsdf +mvs
Flink SQL realizes the integration of stream and batch
考研线性代数常见概念、问题总结
[Luke V0] verification environment 2 - Verification Environment components
LeetCode396. Rotate array
Applet error: cannot read property'currenttarget'of undefined
Applet error: should have URL attribute when using navigateto, redirectto or switchtab
Go language self-study series | golang nested structure
108. Convert an ordered array into a binary search tree
A must see wechat applet development guide 1 - basic knowledge
Vivo, hardware safe love and thunder
Base de la technologie électronique numérique 3.1 aperçu du circuit de porte, 3.2 circuit de porte à diode semi - conductrice
EmuElec 编译总结
Go language self-study series | golang structure pointer
npm ERR! network