The if statement
if (condition) {
statements executed during the establishment of the conditions;
} {statement executed when the condition is not satisfied;} else
prompt [prɑːmpt]
prompt ( "content of the dialog prompt");
// such as: var age = prompt ( "content of the dialog prompt"); the contents so that the user input is equal to age.
alert [əˈlɜːrt]
alert ( "warning dialog content");
length [leŋθ]
abc.length, get the length of the string abc, the return value is the number
new Date().getDay()
A few, the value returned is acquiring the week number (0-6).
switch statement
switch (function) {
Case Value 1: When the function is equal to a value of 1, the statement is executed;
BREAK;
Case 2 values: when the function value is equal to 2, the statement is executed;
BREAK;
...
default: When the above functions are not equal when the value of the statement is executed;
}
document.write()
document.write ( "Content"); output "content" to the browser.
for loop
for ( < initial condition > ; < loop condition > ; < end loop > ) { < intermediate loop > ; } // do first initial condition 1 // 2 loop condition is satisfied is determined @ 3 into the intermediate cycle if the establishment of body, if established directly out // intermediate 4 after executing the loop, the loop is then performed at the end of the 5 // End executed at the end loop, then perform 2
while loop
while (loop condition) { // if the loop proceeds to the loop condition is satisfied, otherwise skip < loop > }
do while loop
{do // loop proceeds directly, without determining < loop > } the while (loop condition); // if the loop condition is satisfied, then re-enters the loop
Note: If you know the fixed number of times with for ; if you must perform once the while with do ; otherwise use the while .
break与continue
We encounter a break in the cycle, directly out of the loop.
Encounters continue in the cycle, the end of the cycle (the latter statement is not executed), the next cycle resumes.