JavaScript operator-3

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

Learning Goals

1. Mastering What is an expression

2. Mastering The classification of JavaScript operators

3. Mastering Arithmetic Operators

What is an expression

The meaningful expression of a type of data (as usual, a variable, a function, etc.), which is linked by an operation symbol to a certain rule, is called an equation.

Classification of operators

1. Arithmetic Operators

2. logical Operators

3. Assignment Operators

4. comparison Operators

5. ternary operator

arithmetic operator (implicit type conversion "5")

+: Add

-: Minus

*: Multiply

/: Except

%: Take the remainder

Increment and decrement

1. Increment

++a and a++ are both incremental operations

difference:++a First returns the value of a after increment (1+a)

a++ First returns the original value of a , and then returns the value after increment

2. diminishing the same

JavaScript Operators

Learning Goals

1. Mastering the assignment operator

2. Mastering comparison Operators

3. Mastering Ternary operators

Assignment operator

simple assignment:=

Compound Assignment:+ =,-=,*=,/=,%=

Comparison operators

>,<,>=,<=,= =, = = =,! =,! ==

= =: Equal, only compare values are equal

= = =equals, compares values while comparing data types for equality

! =: Not equal, the comparison value is not equal

! = = =Not equal, compare values while comparing data types for equality

return value: type Boolean

Ternary operator

var soce=55;

Var result= (soce>=60)? "Pass":" fail"

Console.log(result)

syntax: Condition? Execute code 1: Execute code 2

Description: Can replace a simple if statement, if the condition is true, execute code 1, otherwise execute code 2

JavaScript Operators

Learning Goals

1. Mastering the classification of logical operators

2. Mastering logical operators

logical operators

&&: With, and

| |: or

! : Non-

&&: With, and (All conditions are true at the same time .) Only one condition is not true, return false)

Note: In cases where an operand is not a Boolean value, the logic and operation do not necessarily return a value.

At this point it follows the following rules:

1. returns the last operand if the first operand is true after an implicit type conversion

2. if the first operand is false after an implicit type conversion , the first operand is returned

3. returns null If one of the operands is null

4. if one of the operands is nan, the nan is returned

5. if one of the operands is undefined, return undefined

| |: or (as long as one condition is set, returns true)

Note: In cases where an operand is not a Boolean value, the logic and operation do not necessarily return a value.

At this point it follows the following rules:

1. if the two operand is true after an implicit type conversion , returns the first operand

2. if the first two operand is false after the implicit type conversion , the second operand is returned

3. If there are two operands that are null, return null

4. If there are two operands that are nan, the nan is returned

5. If there are two operands that are undefined, return undefined

! : Non-

Description: 1. no matter what type the operand is, the logic will return a Boolean value

2.!! Use two logical non-operating characters simultaneously:

the first logical non-operation will return a Boolean value based on whatever operand

The second logical negation is a Boolean value.

JavaScript operator-3

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.