Talk about the variables in JavaScript.
The advantage of using variables in JavaScript is that variables are stored in the computer's memory, and variables are well suited to saving temporary data, and variables have limited lifetimes, when
When the user closes the page or opens a new page, the variable is released.
In JavaScript code, variable names are case-sensitive, and some specific words or characters cannot be used as variable names, and these specific words are in JavaScript
Reserved words, such as: Var, with, and so on, some special characters cannot be used in variable names, such as the & character and percent percent percent character. JavaScript variable names can be used in several
character, but the number cannot be the beginning of a variable name.
Some of the illegal variable names are listed below:
reserved word in Var//javascript
12AD//Digital start
H&DG//contains & characters
H%ji//contains% characters
<span style= "FONT-SIZE:14PX;" ></span>
Some valid variable names are listed below:
Helloworld23
Hello_world
When defining variables, we should use canonical names to name them, such as declaring names:
var name;
Next look at the example code:
<span style= "FONT-SIZE:14PX;" >
The browser loads the file and pops up a message box (alert is a message box):
The variable myname is displayed in the message box as Billgu
At first, there was no assignment for MyName, when the initial value of myname was undefined, then MyName was assigned BILLGU, and alert was invoked as a message box
appears, when you click the OK button, another message box appears:
we can see in the message box that the display is: 1234
when MyName is re-assigned, the original value of the variable is lost, and in JavaScript, a process called garbage collection is automatically
Interpretation put memory that is not being used. When JavaScript detects that a variable is not being used, or a variable that references an object is given a new
Value, the garbage collection process is automatically run to free the memory space that these variables occupy.
reprint Please indicate source: http://blog.csdn.net/hai_qing_xu_kong/article/details/40760675 Emotional Control _ Click to open the link
JavaScript Language Basics 4