javascript based learning on the third day

☞ nomenclature: small and large hump hump nomenclature nomenclature (Pascal nomenclature)

Variable naming rules: follow the small hump nomenclature [first lowercase first letter after letter variable name of each word capitalized]

var userNameAge;


Function naming rules: follow Pascal nomenclature [the first letter of each word in the function name and the first letter should be capitalized later]


☞ logical operators shorting

1. The operation and the short-circuit

✔ if the first value by the implicit type conversion is true, then directly returns the last value.

✔ if the first value by the implicit type conversion is not true, then returns the result of an implicit type conversion

Summary:
☞ logical operators will appear in short circuit (not required to return a Boolean result, it is possible to return other results)
☞ If the operation is and then by the short-circuit operation returns the last value


Learning objectives:
1. The circulation can be used to complete the relevant case
2 can use the data array manipulation program


1. cycle: repeatedly doing something.

☞ while loop: one thing repeatedly executed. [When] conditions are met the

☞ syntax:

while (conditional expression) {

Logic loop Code Code]
}

☞ cycle analysis of the implementation process:

1. First, determine the conditional expression is established (true or false)

2. If the conditional expression is true, then the program will immediately enter into the body of the loop code

3. If the conditional expression is false, then the routine is ended immediately loop body code.

Summary: The conditions have been iteration of the loop the code, otherwise not executed.


☞ cycle time Note:

1. To clear the loop body to achieve what function

2. what conditions must be clear when the fullness of time necessary to execute the code in the loop body

3. To pay attention to the end of the cycle conditions (must be written, is dead if you do not write cycles)


2. do ... while ... loop

Syntax:

do {

Loop

} While (conditional expression)


☞ execution

1. The first iteration of the loop code is

2. determine whether the conditions established

3. If the condition is true then continue to execute code in the loop body, and otherwise does


The difference between the cycle while:

☞ do while in the implementation of the program, the first implementation of the code in the loop body, and then determine whether the conditions established [condition regardless of the establishment or not, the code will be executed in a loop]


☞ program executed when the while loop, the first determination condition, only the conditions are met, will execute the code in the loop body


☞ assumptions are not satisfied, do while loop is executed once, while a loop is not executed.


☞ Under what circumstances consider the use of do while loop?

Regardless of whether the conditions established, they have to survive a program, consider using do. . . while loop


Summary: The conditions have been iteration of the loop the code, otherwise not executed.


3. for loop: when the number of times a program can clear circulating recommended priority use a for loop.

grammar:

for (variable initialization; conditional expressions; variable increment (decrement)) {

Loop Code
}

Implementation process:

1. The first implementation of variable initialization

2. determine the conditional expression is satisfied (true | false)

3. When the conditional expression is true, when the program code is executed immediately in the loop

4. After completing the loop code, and then perform variable increment (decrement)

5. Continue judgment condition is satisfied, if the establishment continues

6. If the conditional expression is not satisfied (false), then the loop body code immediate end

Summary: the implementation conditions are met, the condition is not satisfied is not executed


Notes:
1. The syntax must be separated by semicolons

2. General initialize variables are initialized only one variable [which variables behind the expression used, which is initialized variable]

Note:
1. Can not compare the size of a decimal in the js.


4. break and continue keywords keywords

☞ break: When the program encounters a break keyword, will end the program immediately behind the code is no longer executed.

Summary:

1. If the program loop is performed when the brek statement, the entire cycle is ended immediately behind the code is no longer performed

☞ continue: Continue

Summary:
1. If in the loop when the program encounters contine statement, when this cycle will end immediately enter the next cycle.

Guess you like

Origin www.cnblogs.com/szq123/p/11260721.html