Kidney Day Arch A stroke JavaScript series CHAPTER4 statements

Source: Internet
Author: User

Chapter 4 Statement

Formally, a statement is a piece of code that ends with a semicolon. Whether this code is an expression, something else, or even nothing, as long as it ends with a semicolon, it can be considered a statement.

Functionally, a statement implies the meaning of "making something happen" (make something happen).

By enclosing multiple statements in curly braces, a compound statement (statement block) is formed.

JavaScript programs is nothing more than a sequence of statements to execute.

1. Condition condition

1.1 If statement

1.2 Switch statement

switch (expression) {

Case Value-1:statement

break;

Case Value-2:statement

break;

Default:statement

}

If you omit a break, it means merging two scenarios.

Value can also be a Boolean expression.

2. Loop loops

2.1 While Statement

Front-facing detection.

2.2 Do-while Statements

After detection, the code will be executed at least once.

2.3 For statement

2.4 for-in Statements

The property used to enumerate objects.

For (Val in object) {}

The statement iterates through the properties of the object and assigns the property name to Val in turn.

JavaScript built-in object properties are not enumerable.

If a property value exists with null or undefined, the loop terminates. It is therefore better to test before using for-in.

3, Jump Jumps

3.1 Label statement

A label can be used to represent a loop, similar to a variable, and then used in conjunction with break or continue to implement nesting loops in a loop.

3.2 break&continue

Controls the execution flow of code in a loop.

Break exits the loop immediately.

Continue also exits the loop immediately, and then the loop continues to execute from the top. Continue to express the meaning of "skip the next step, go straight to the following cycle".

3.3 Return

Used to specify the return value after a function call. It can only be used in functions.

3.4 Throw

Throws an error, stops execution of the current code, jumps to the nearest exception handler.

Exception handlers: try/catch/finally

Attached: JavaScript statement list

Kidney Day Arch A stroke JavaScript series CHAPTER4 statements

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.