JS commonly used in the loop and other

Source: Internet
Author: User

1. Conditional statements

if (conditional statement)
{EXECUTE statement 1}
Else
{EXECUTE Statement 2}


2. Looping statements

For (variable, judge, variable increment/subtract) {EXECUTE statement}

For: The variable is executed after the judgment statement is incremented, and the condition is not executed after the



3.while and Do While

while (expression 1) {expression 2;} expression 3;

While the expression 1 is judged, conforms to the conditional execution Expression 2, does not conform to the conditional execution Expression 3

do{expression 1;}while (expression 2); expression 3;

Whether or not the condition is met, the expression 1 is executed, the expression 2 is judged, and the expression 3 is executed, and the loop can execute at least once


4. Data type

Data types are divided into raw data and reference data.
The original data is divided into number, string, Boolean, null, undefined, with typeof to query the data type, except that null returns an object, the rest of the original data is the return of their own data type.
Reference data types are classified as object, array, function, NaN. When a data type query is made with TypeOf, object, array returns object,function returns Function,nan returns number.

5.parseInt (value) converts the argument to an integer.

6. Output mode: 1) alert (""); pop-up box shows "" Inside content
2) Console.log (""), Background display "" Inside content
3) document.write (""); Display the contents of "" in the Web page

JS commonly used in the loop and other

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.