The JavaScript operator

Source: Internet
Author: User
Tags arithmetic

Tag: ASC uses the priority conditional arithmetic structure to reverse the calculation assignment

The JavaScript operator

Arithmetic operations
Addition Operator (addition): X + y
Subtraction operator (subtraction): x y
Multiplication operator (multiplication): X * y
Division operator (Division): X/Y


Remainder operator (remainder): x% y
Self-increment operator (Increment): ++x or X + +
Self-decrement operator (decrement):--x or x--
Negation operator (Negate):-X

Assignment operations

Comparison operation
Character encoding: All numbers, letters, and other symbols in a computer are numbered. This facilitates data transfer of charCodeAt ()
If it is more than one character, it is compared individually. (Unicode encoding of characters.) This return value is an integer between 0-65535)

Logical operations

logical non , can be used for any value. The first is converted to a Boolean value, then the inverse (also called the inverse operator)

Expected Boolean value: undefined null ' 0 NaN-->false remainder is True

logic with , there are more than two operands, judging whether all two of them will return true

logical OR , two or more operands, judging if there is a return true of two

logic and , logically, are not also known as short-circuit operators.
Example: Var b_flag=true;
var b_flag2=b_flag&& A;
Console.log (B_FLAG2);

var B_flag=false;
var b_flag2=b_flag&& A;
Console.log (B_FLAG2);

Conditional operations
ternary operation: ? :


Precedence of Operators

Priority level Type of operation Operator uses
19 Parentheses ()
18 New member access to array access . [ ]
17 Function call Fn
16 Post Increment and decrement ++    - -
15 Logical non, forward increment decrement typeof ! ++    - -
14 Multiplication to take the remainder *  /  %
13 Add and Subtract +    -
11 Greater than or equal to < > =
10 equals all equals not equals not equal to ==    ===    !=     !==
6 Logic and &&
5 Logical OR ||
4 Ternary operations ? :
3 Assign value =

1, good at using parentheses operator
2, remember the precedence of operators

Assignment is very low, the right expression is evaluated first, and then the left side is assigned

Program Order Execution Structure
The sequential structure of the program is strictly in accordance with the code in the program execution, if there is a choice structure, according to the specific conditions
Execute the appropriate code. The loop structure will also have conditional judgments, which will execute different code depending on the situation. Some
There are also interactive technologies that respond to user requirements or external circumstances.

The JavaScript operator

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.