Web Second Stage Java Script (cont.)

Source: Internet
Author: User
Tags arithmetic operators logical operators null null

One, Nan is all called not a number:the output of the data type of nan is, and the numeric type is.

Second, the number type:1, as an identity, identify a certain data is not a number type No.

2, any nan calculation, will return nan

3. NaN is not equal to any value, including his own

4. in the ES is specifically judged as a non-number function IsNaN ()

Third, numeric Conversion related functions: 1, numeric type Number (): Converts a value to numeric

2. if it is a Boolean value Boolean, it will be converted to 0 or 1 .

3. if it's a number, it's a simple return.

4. if null, returns 0

5. if undefined is undefined , returns NaN

Four, unary operators:+ + and --

1. if + +(--) is placed in front of the operand , then it is self-increment, which is involved in the Operation .

2. if it is put it in the back . , it participates in the operation first and then increases itself.

3. try to reduce the difference between + +(-) in front or behind , i++ or ++i Write a single line.

Five,  logical operators: With or non-

1. with: say two is true, is true, if there is a false, then is false.

(1), and, Short Circuit phenomenon : The so-called short-circuit phenomenon, that is, as long as the first number is false, then will not judge the second number, because the second operand, whether true or false, the result is false.

2. or: or inside as long as there is a true, then return True.

(1), OR, There is also a short-circuit phenomenon. If the first operand is true, then the second one is not judged.

3. Non-: is to take the opposite. Not true or FALSE, true or false, the operator used is one !

Vi. Special Cases:

1. if the two operands are Nan, the return is nan.

2. if the two operands are null NULL, NULL isreturned .

3. if the two operands are undefined undefined, the undefinedis returned without a definition.

4. two are true, return the first operand

Seven, Arithmetic operators: addition, subtraction, multiplication, division, modulo, exponential operator

1, take the mold: is the remainder in mathematics. Operator is a %

Eight, exponential operator:

1. in the before ES6, there was no exponential operator, we asked the second party to call the pow () method of the Math Object

2. Relational operators:  Greater than less than  greater than or equal  less than or equal  Equal  Not Equal  congruent not congruent

(1), and will eventually return a Boolean value

(2), In addition to numbers, letters can also be compared to size, and comparisons are ASCII corresponds to the character encoding.

(3), if a string and a number are compared, the string will be implicitly converted to a number, if not converted, to NaN

(4), NaN and any type are compared, false false is returned

Nine,  Equal  Not Equal  congruent not congruent

1,= =: values are equal, but data types can be unequal

2,= = =: values are equal and data type types must be equal

10. Assignment operators:

1. =: In addition to =, there is a set of compound assignment operators + = = *=/=%=

Xi. Other operations:

1. Three mesh operator ?:

2. syntax: expression 1? Expression 2: Expression 3

3. If expression 1 is true, then the expression 2is executed, and if expression 1 is false, then the expression 3 is executed .

4. comma operator: operator Precedence is high-to-low

5, you can use parentheses to change precedence

The third chapter chooses the structure:

1. The concept of Process Control: the flow direction of controlling program (direction of the point)

2. common structure of the program: (1) Sequential structure: code a line from top to bottom, followed by execution.

(2) Select structure:

<1> Single branch: If the condition is established, then enter into the branch conditions, execute the corresponding code, if not set up will not go in.

(3) the keyword used is if

(2) Dual branch: that is, if the condition is true, enter the code block to execute the statement, otherwise enter another code block to execute the statement

<2> Keyword:if...else

<3> Dual Branch has a simple notation: three-mesh operator

          (3) Multi-branch: If a condition is true, then the corresponding code block is entered.

<1> Keywords:if...elseif...else

3, Switch statement: is equivalent to a multi-branch statement (if. ElseIf. else)

4. The function of the break Boolean type : Jump out of s is witch

5. Default: It is not necessary to write, we write default, just for a precautionary measure.

(1) In ES , unlike other static languages, The value behind a case is not necessarily a constant, it can be a variable or even an expression

(2) compared to If. else If...else,theswitch statement structure is more readable

Web Second Stage Java Script (cont.)

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.