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 |