JavaScript Language Basics 13

Source: Internet
Author: User

Talk about looping statements in JavaScript---------for statements

for (Var value=1;value<10;value++) {
}
First take a look at the above code, we analyze the part of the For statement

var value=1: Initializing the loop variable

VALUE<10: Cyclic Judging conditions

value++: Increments the loop variable (or it can be a decrement variable)

{}: code block in the loop body executed

Then we clean up the execution process:

1. Execute the initialization portion of the for statement.

2, check the loop to determine the condition, if true, continue to execute the FOR statement, if False, the For statement is introduced.

3. Execute the code in the loop body in the for statement.

4. The increment part of the loop variable that executes the For statement (descending part).

5. Repeat steps 2nd through 4th.

Then we look at the complete code:



After reading the For statement, let's take a look at the for...in Loop statement

For...in Loop statement: Mainly used for array type and object type data, to traverse the data, do not need to know the number of data.

Look at the following code:




For an array, see http://blog.csdn.net/hai_qing_xu_kong/article/details/40934835


Reprint Please specify source:http://blog.csdn.net/hai_qing_xu_kong/article/details/41356699 Emotional Control _

JavaScript Language Basics 13

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.