JavaScript Expressions and operators

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise

1. Expression type

After you have defined the variables, you can assign them, a series of operations, such as change, computation, and so on, usually called an expression, that is, a set of variables, constants, Boolean, and operators, so that an expression can be divided into arithmetic expressions, string expressions, assignment expressions, and Boolean expressions.

2, operator

The functions and usages of the operators are shown in table 2-1.

Table 2-1 commonly used operators in JavaScript

Type Symbol Description Example Results
Arithmetic operators Negative -3 -3
* Multiplication 5*3 15
/ Division 5/2 2.5
% Take more 5mod2 1
+ Addition 5+3 8
Subtraction 5-3 2
| Bitwise OR operation 5|3 7
Bitwise AND Operation 5&3 1
<< Move left 5<<3 40
>> Move right 5>>1 2
~ Take a supplement ~5 -6
++ Accumulator A=5 a++ A=6
-- Decline A=5 a-- A=4
Character operators + string concatenation "A" + "B" "AB"
Comparison operators = = Equals 5==3 False
!= Not equal to 5!=3 True
< Less than 5<3 False
> Greater than 5>3 True
<= Less than or equal to 5<=3 False
>= Greater than or equal to 5>=3 True
Logical operator ! Logical non ! True False
& Logic and True & False False
| Logical OR True | False True
^ Logical XOR or True ^ False True

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.