JS Basic (c) statement

Source: Internet
Author: User

I. Judgment statement (PS: In general, the judging condition should ultimately be a Boolean value.) )

1.if statements

1) Basic format

if (judging condition) {The    statement executed if the condition is determined}else{The    statement executed if the condition is not established}

2) Extended format (two-way selection statement)

if (judging condition) {The    statement executed if the condition is determined}else{The    statement executed if the condition is not established}

3) Extended Format 2

if (condition 1) {    The statement executed immediately if condition 10%}else if (condition 2) {    If the preceding conditions are not true, condition 20% executes immediately}...else{the statement executed    when all conditions are not true}

Two. Multi-path Selection statement switch

Switch (judging value) {Case    comparison value 1:        when the judgment value equals to the ratio 1 o'clock execution of the statement;    break;    Case Comparison Value 2:        when the judgment value equals to the ratio 1 o'clock execution of the statement;    break;    ....    Default:        statements executed when all judgments are not equal to the value of the comparison}

Three. Looping statements

1.for Cycle

for (initialize; loop condition; statement executed after Loop) {        statement executed when loop condition is set}

2.while Cycle

while (loop condition) {    The statement executed when the loop condition is established;}

3.do...while Cycle

do{    When a loop condition is established, the statement}while (loop condition) is first cycled without conditional judgment. At any rate, the Loop statement executes at least once.

Four. Break statement: Exits from the current function and returns a value from that function

Five. Continue statement: Stop the current loop of the loop

Six. Return statement: Exit from the current function and return a value from that function

JS Basic (c) statement

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.