In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-10-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to understand JavaScript pre-parsing and objects. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
1. Pre-analysis 1. Variable pre-analysis and function pre-analysis.
The JavaScript code is executed by the JavaScript parser in the browser. The JavaScript parser runs JavaScript code in two steps: pre-parsing and code execution.
Pre-parsing: in the current scope, the browser will declare or define variables with var and function declarations in memory by default before the JS code is executed.
Code execution: executes the JS statement from top to bottom.
Pre-parsing occurs only on variables and function defined by var. Learning pre-parsing can let us know why the value of the access variable is undefined before the variable is declared, and why the function can be called before the function is declared. Pre-parsing is also called variable and function promotion.
1. Variable pre-analysis
Variable pre-parsing: the declaration of the variable is promoted to the top of the current scope, and the assignment of the variable is not promoted.
For example:
/ * first parse the var variable num, then execute the console output and finally assign 10 to num*/console.log (num); / / what is the result? Var num = 10; /? 2. Function pre-analysis.
Function preparsing: the declaration of the function is promoted to the top of the current scope, but the function is not called.
/ * parse the definition of the fn function first and then execute the console statement * / console.log ("1 / 2 / 3 / 1 / 2 / 3 / 1 / 2 / 3 / 1 / 3 / 1 / 3 / 1 / 3 / 1 / 3 / 1 / 3 / 1 / 3 / 1 / 3 / 1 / 2 / 1 / 3 / 1 / 3 / 1 / 2 / 1 / 3 / 1 / 2 / 3 / 1 / 3 / 1 / 3 / 1 / 2 / 3 / 1 / 2 / 3 / 1 / 3 / 1 / 1 / 2 / 1 / 2 / 3 / 1 / 3 / 1 / 3 / 1 / 2 / 3 / 1 / 2 / 3 / 1 / 1 / 2 / 3 / 1 / 3 / 1 / 2 / 3 / 1 / 3 / 1 / 2 / 3 / 1 / 2 / 3 / 1 / 3 / 1 / 2 / 3 / 1 / 2 / 3 /
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.