Javascript series: ecmascript statements

Source: Internet
Author: User

1. If statement

If statement Syntax:

 
If(Condition) statement1ElseStatement2

2. Iterative statements

An Iteration statement is also called a loop statement. It declares a group of commands that need to be executed repeatedly until certain conditions are met. Ecmascript provides four types of iteration statements for this processing.

2.1 Do-while statement

The do-while statement is a post-test loop, that is, the exit condition inside the execution loopCodeAfter calculation. The loop subject is executed at least once before the expression is calculated.

Do-while Syntax:

 
Do{Statement}While(Expression)

2.2 While statement

The while statement is a pre-test loop, that is, the exit condition is calculated before the code in the execution loop.

While Syntax:

 
While(Expression) Statement

2.3. For statement

The for statement is a testing loop. before entering the loop, you can initialize the variable and define the code to be executed after the loop.

For Syntax:

 
For(Initialization; expression; post-loop-expression) Statement

2.4 for-in statements

A for-in statement is a strict iteration statement used to enumerate the attributes of an object.

For-in syntax:

 
For(PropertyInExpression) Statement

3. Statements with labels

Tag statement Syntax:

  

 
Start:VaRCount = 10;

4. Break and continue statements

The break and continue statements provide stricter control over the code execution in the loop. The break statement can immediately exit the loop to prevent repeated execution of any code. The continue statement only exits the current loop and allows execution of the next loop based on the control expression.

5. With statement

The with statement is used to set the scope of code in a specific object.

With Syntax:

 
With(Expression) Statement

6. swith statements

Swith statement Syntax:

 Swith (expression ){  Case  Value: Statement  Break  ;  Case  Value: Statement  Break  ;  Case  Value: Statement Break  ;......  Case  Value: Statement  Break  ;  Default  : Statement  Break  ;} 
Related Article

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.