Third day JavaScript operator (cont.)

Source: Internet
Author: User
Tags logical operators

1, post increment/decrement operator ++,--

such as: Var i=0;

var a=i++;

Console.log (a);

2 . Comparison operator (<, >=, <=, = =,!=,===,!==)

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, value equal

3, logical operators (&&, | |,!)

&&: Logic and

|| : Logical OR

! : Logical Non-

var i = 8;

Alert (i<5 && i<10); Outputs false

Alert (i > | | i < 10); Outputs True

Alert (! (    > 5)); Outputs false

Second, the program flow control

1. Conditional Statement if

Grammar:

if (condition) Statements1 else statement2

Cases:

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");

}

2.switch Statement

Grammar:

switch (expression) {

Case Value:

Statement

Break

Case Value:

Statement

Break

Default

Statement

}

Cases:

var i = 25;

switch (i) {

Case 25:

Alert (i + "equals 25");

Break

Case 100:

alert (100);

Break

Default

Alert (' other ');

}

Third day JavaScript operator (cont.)

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.