JavaScript Learning notes--javascript Process Control

Source: Internet
Author: User

JavaScript Process Control
Process: is the execution order of the program code.
Process Control: The program code is conditionally executed in a certain way through the prescribed statements.

First, sequential structure
Execution in the order of writing is the most basic process structure in the program.

II. selection structure (branching structure, conditional structure)
The corresponding statement of the selected execution shape according to the given condition.
(1) If else if else


1. Single-channel branch
The condition can either be an expression or any data type
Curly braces will run the code inside of him as a whole, and if there is only one statement, you can omit the curly brace
if (condition) {
Statement of conditional execution
}


2. Two-way Branch

if (condition) {
Code executed when the condition is set
}else{
Code that executes when the condition is not established
}


3. Multi-Channel Branch
if (condition 1) {
Condition 1 The code of execution is established
}elseif (condition 2) {
Condition 2 The code of execution is established
}elseif (condition 3) {
Condition 3 The code of execution is established
}......else{
If the above conditions do not establish the code of execution
}


4. Nesting branches
if (condition 1) {
if () {
}elseif () {

}....

}elseif (condition 2) {
Condition 2 The code of execution is established
}elseif (condition 3) {
Condition 3 The code of execution is established
}......else{
If the above conditions do not establish the code of execution
}
(2)
switch (any data type of the variable) {
Case value 1:
Expression 1;
Break
Case Value 2:
Expression 3;
Break
.........
Defalut:
An expression
}
Multiple selections to match accordingly

*************************************************
1. It is best to use an if statement when judging a range, and switch when judging a single value
2. Conditions can not be repeated, unexpected errors occur.
*************************************************
Third, the cycle structure

JavaScript Learning notes--javascript Process Control

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.