Want to know how to declare static variable in javascript? we have a huge selection of how to declare static variable in javascript information on alibabacloud.com
Do you know the value of alert following JavaScript execution?
var foo = 1;
function Bar () {
if (!foo) {
var foo =;
alert (foo);
}
Bar ();
If you're surprised by the result of "10," you might want to take a good look at this article:
var a =
The static keyword is very common in C # programming, and it is used to declare static members that belong to the type itself rather than to a particular object. The static modifier can be used for classes, fields, methods, properties, operators,
Variable creation in js is usually called a "Declaration" variable. Next I will introduce some basic JavaScript variable declaration and usage methods. I hope this tutorial will be helpful to you.
Variable Declaration
JavaScript uses the keyword var
Static variables and static variables in PHP use detailed, static use detailed
Static variables exist only within the scope of the function, that is, the static variables only live in the stack. General function variables are released after the
Analysis of JavaScript variable replication, parameter transfer and scope chain, analysis of javascript
Today, while reading a book, I found a vague knowledge of Javascript: the scope chain of JS, therefore, I learned the content related to the
JS in the declaration of global variables are mainly divided into explicit declarations or implicit declarations are described below respectively.Declaration Method One:The use of the Var (keyword) + variable name (identifier) is declared outside
JS in the declaration of global variables are mainly divided into explicit declarations or implicit declarations are described below respectively.Declaration Method One:The use of the VAR (keyword) + variable name (identifier) is declared outside
1.JavaScript variable boostIn JavaScript, the declarations of functions and variables are promoted to the topmost part of the function.In JavaScript, variables can be declared after they are used, that is, variables can be declared using the
Static variables exist only within the scope of the function, that is, the static variables only live in the stack. General function variables are released after the function ends, such as local variables, but static variables do not. That is, the
JavaScript object-oriented is totally accidental, because most of the time I work in a non-graphic environment, sometimes when I write JavaScript and ajax, even when I get involved in the work of the web Client, the most important thing is writing a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.