Javascript basic tutorial arithmetic operators
|
Addition |
x y |
|
加法 |
x y |
如果x为整数2,y为整数5, x y等于7
如果x为字符串"text1", y为字符串"fun",
x y则等于"text1fun"
|
- |
减法 |
x-y |
|
* |
乘法 |
x*y |
|
/ |
除法 |
x/y |
|
% |
两者相除求余数 |
x%y |
如果x等于10, y等于3, x%y结果等于1 |
|
递增 |
x |
如果x等于10, x 等于11 |
-- |
递减 |
y-- |
如果y等于10, y--等于9 |
If x is an integer 2 and y is an integer 5, x y is equal to 7
If x is the string "text1" and y is the string "fun",
x y is equal to "text1fun"
== |
等于 |
x==y |
如果x等于2, y等于2,则x==y |
=== |
全等于(值相等,数据类型也相等) |
x===y |
如果x等于整数2,y为字符串"2",
则x===y不成立
|
> |
大于 |
x>y |
|
>= |
大于等于 |
x>=y |
|
< |
小于 |
x
| |
<= |
小于等于 |
x<=y |
|
!= |
不等于 |
x!=y |
|
!== |
不全等于 |
x!==y |
|
&& |
与(and) |
x < 10 && y > 1 |
|
! |
非(not) |
!(x==y) |
|
|| |
或(or) |
x==8 || y==8 |
|
|
- |
Subtraction |
x-y |
|
* |
Multiplication |
x*y |
|
/ |
Division |
x/y |
|
% |
Divide the two and find the remainder |
x%y |
If x equals 10, y equals 3, the result of x%y is equal to 1 |
|
Increment |
x |
If x equals 10, x equals 11 |
-- |
Decreasing |
y-- |
If y is equal to 10, y--is equal to 9 |
Javascript basic tutorial logical operators
== |
equals |
x==y |
If x equals 2 and y equals 2, then x==y |
=== |
All equal (the values are equal and the data types are also equal) |
x===y |
If x is equal to the integer 2, y is the string "2",
Then x===y is not true
|
> |
Greater than |
x>y |
|
>= |
Greater than or equal |
x>=y |
|
< |
less than |
x
| |
<= |
Less than or equal |
x<=y |
|
!= |
not equal |
x!=y |
|
!== |
Not all equal |
x!==y |
|
&& |
and(and) |
x < 10 && y > 1 |
|
! |
Not (not) |
!(x==y) |
|
|| |
or(or) |
x==8 || y==8 |
|
Javascript basic tutorial assignment operator
Note: Please pay attention to the difference between assignment (=) and equal (==).