当前位置:网站首页>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
边栏推荐
- To remember the composition ~ the pre order traversal of binary tree
- 员工试用期转正申请书(泸州老窖)
- Applet error: should have URL attribute when using navigateto, redirectto or switchtab
- 《數字電子技術基礎》3.1 門電路概述、3.2 半導體二極管門電路
- 错题汇总1
- Summary of wrong questions 1
- Brush classic topics
- LeetCode_ DFS_ Medium_ 1254. Count the number of closed islands
- Go language learning notes - slice, map | go language from scratch
- MySQL of database -- basic common query commands
猜你喜欢
Kettle experiment conversion case
机器学习(六)——贝叶斯分类器
[58] length of the last word [leetcode]
Kettle experiment (III)
Applet error: cannot read property'currenttarget'of undefined
Production practice elk
[Luke V0] verification environment 2 - Verification Environment components
《信息系统项目管理师总结》第八章 项目干系人管理
Kettle实验 (三)
Open services in the bottom bar of idea
随机推荐
Thread scheduling (priority)
Unfortunately, I broke the leader's confidential documents and spit blood to share the code skills of backup files
SQL used query statements
[58] length of the last word [leetcode]
The most concerned occupations after 00: civil servants ranked second. What was the first?
Applet in wechat and app get current ()
How does kubernetes use harbor to pull private images
npm报错 :operation not permitted, mkdir ‘C: \Program Files \node js \node_ cache _ cacache’
Employee probation application (Luzhou Laojiao)
Learn FPGA (from Verilog to HLS)
Base de la technologie électronique numérique 3.1 aperçu du circuit de porte, 3.2 circuit de porte à diode semi - conductrice
【SQL server速成之路】数据库的视图和游标
653. Sum of two IV - input BST
三、6【Verilog HDL】基础知识之门级建模
Summary of wrong questions 1
小程序报错 :should have url attribute when using navigateTo, redirectTo or switchTab
[Luke V0] verification environment 2 - Verification Environment components
Go language self-study series | golang nested structure
[SQL Server fast track] view and cursor of database
2D 01 Backpack