JS Summary three ...

Source: Internet
Author: User

1. Operators: Add, subtract, multiply, divide, and seek redundancy.

var total = (1 + 4);

var i = 100;

var temp = (i-20)/2;

Alert ("ten" +)//return1020;

Alert (ten +)//return30;

2. Post Increment/decrement operator: + +/--

var i = 10;

var a = i++; i = i + 1;

alert (a); A = 10;

var a = ++i; i = i + 1;

alert (a); A = 11;

Tip: Execute from left to right, if a = i++, then A is first equal to I, then I is added;

If a = ++i, then the ++i is executed first and then assigned to a.

3. Comparison operators:>, <, =, >= <=, = =, = =,! =,!===

Alert (> 5); Outputs true;

var i = 100;

var n = 100;

alert (i = = n); outputs true;

Alert (i! = n); outputs false;

alert (i = = N)//data type and value all want to wait.

4. Logical operators:&&, | |,!

&&: Logic and;

|| : Logical OR;

! : logical non;

var i = 8;

Alert (I < 5 && i < ten); output false;

Alert (i > | | i <); output true;

Alert (! ( 10>5)); Outputs false;

5. Program Flow control:

A. Conditional statement if:

if (> 5) {

Alert ("Hello World");

}

var i = 90;

if (i > 100) {

Alert (i + "greater than 100");

}else if (i > 80) {

Alert (i + "greater than 80");

}else {

Alert (i + "less than 100");

}

B.switch statement:

var a = B;

Switch (a) {

Case "A":

Alert ("You have selected a");

Break

Case "B":

Alert ("You have selected B"); Carried out this.

Break

Case "C":

Alert ("You have selected C");

Break

Default

Alert ("Welcome to the next time!") ");

}

JS Summary three ...

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.