JavaScript Summary 2--Process Control

Source: Internet
Author: User

Process Control in JavaScript is basically the same as Java

Divided into sequential structure, selection structure (branching structure, conditional structure), cyclic structure

1. Sequential structure

is executed in the order of writing, which is the most basic structure in the program.

2. Select structure

2.1 If-else Statements

if (Grade >) {     document.write ("excellent");} Else if (Grade >) {     document.write ("good");} Else if (Grade >70) {     document.write ("Medium");} Else if (Grade >60) {     document.write ("pass");} Else {     document.write ("failed");}

2.2 Switch statement

Switch (tel) {    case ' document.write ':    ("Police alarm telephone");       Break ;     case ' 119 ':    document.write ("Fire alarm call");      Break ;     case ' + ':    document.write ("Hospital rescue Phone");      Break ;}

3. Cyclic structure

3.1 For Loop statement

 for (var i =1; i < temp; i++) {    document.write (i);}

3.2 While Loop statement

 while (I <) {documen.write (i);}

3.3 Do-while Loop statement

 Do {    document.write (i);}  while (1 < 10)

JavaScript Summary 2--Process Control

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.