In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article Xiaobian for you to introduce in detail "JavaScript global variables and life cycle case analysis", the content is detailed, the steps are clear, the details are handled properly, I hope this "JavaScript global variables and life cycle case analysis" article can help you solve your doubts, following the editor's ideas slowly in depth, together to learn new knowledge.
JavaScript global variable
Variables are defined outside the function, that is, global variables.
Global variables have a global scope: all scripts and functions in a web page can be used.
Example
Var carName = "Volvo"
/ / the carName variable can be called here
Function myFunction () {
/ / the carName variable can be called within the function
}
If the variable is not declared within the function (without using the var keyword), it is a global variable.
In the following example, carName is within the function, but is a global variable.
Example
/ / the carName variable can be called here
Function myFunction () {
CarName = "Volvo"
/ / the carName variable can be called here
}
JavaScript variable life cycle
The JavaScript variable life cycle is initialized when it is declared.
The local variable is destroyed after the function has been executed.
Global variables are destroyed after the page is closed.
Function parameter
Function parameters only work within the function and are local variables.
Global variables in HTML
In HTML, global variables are window objects: all data variables belong to window objects.
Example
/ / you can use window.carName here
Function myFunction () {
CarName = "Volvo"
}
After reading this, the article "JavaScript Global variables and Lifecycle instance Analysis" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.