Common Operators in Javascript (Operators)-Basic tutorial in javascript basic tutorial in Arithmetic Operators
Operator |
Operator description |
Example |
Example |
+ |
Addition |
X + y |
If x is an integer of 2, y is an integer of 5, x + y is equal to 7 If x is the string "text1" and y is the string "fun ", X + y equals to "text1fun" |
- |
Subtraction |
X-y |
|
* |
Multiplication |
X * y |
|
/ |
Division |
X/y |
|
% |
Division of the two |
X % y |
If x is equal to 10, y is equal to 3, and x % y is equal to 1 |
++ |
Increment |
X ++ |
If x equals 10, x ++ equals 11 |
-- |
Decrease |
Y -- |
If y equals 10, y -- equals 9 |
Basic javascript tutorial logical operators
Operator |
Operator description |
Example |
Example |
= |
Equal |
X = y |
If x equals 2 and y equals 2, x = y |
=== |
All equals (values are equal, and data types are equal) |
X = y |
If x is equal to integer 2 and y is the string "2 ", Then x = y is not true. |
> |
Greater |
X> y |
|
> = |
Greater than or equal |
X> = y |
|
< |
Less |
X |
|
<= |
Less than or equal |
X <= y |
|
! = |
Not equal |
X! = Y |
|
! = |
Not equal |
X! = Y |
|
&& |
And) |
X <10 & y> 1 |
|
! |
Not) |
! (X = y) |
|
| |
Or (or) |
X = 8 | y = 8 |
|
Basic javascript tutorial assignment operator
Operator |
Operator description |
Example |
Example |
= |
Assignment |
X = 5 |
Assign the value of integer 5 to variable x |
Note:: Pay attention to the difference between value assignment (=) and equal to (=.