JavaScript Basics Tutorial Arithmetic operators
Operator |
Operator description |
Example |
Example description |
+ |
Addition |
X+y |
If x is an integer 2,y is an integer 5, x+y equals 7 If x is the string "Text1" and Y is the string "fun", X+y is equal to "Text1fun" |
- |
Subtraction |
X-y |
|
* |
Multiplication |
X*y |
|
/ |
Division |
x/y |
|
% |
Divide the two to find the remainder |
X%y |
If x equals ten, Y equals 3, the x%y result equals 1. |
++ |
Increasing |
X + + |
x + + equals 11 if × is equal to |
-- |
Decline |
y-- |
If y equals ten, y--equals 9. |
JavaScript Basics Tutorial Logical operators
Operator |
Operator description |
Example |
Example description |
== |
Equals |
X==y |
If x equals 2, and y equals 2, then x==y |
=== |
All Equals (equal value, same data type) |
X===y |
If x equals integer 2,y to the string "2", Then x===y not set up |
> |
Greater than |
X>y |
|
>= |
Greater than or equal to |
X>=y |
|
< |
Less than |
X<y |
|
<= |
Less than or equal to |
X<=y |
|
!= |
Not equal to |
X!=y |
|
!== |
Not all equal to |
X!==y |
|
&& |
With (and) |
X < ten && y > 1 |
|
! |
Non (not) |
! (x==y) |
|
|| |
or (OR) |
x==8 | | Y==8 |
|
JavaScript Basics Tutorial Assignment operators
Operator |
Operator description |
Example |
Example description |
= |
assigning values |
X=5 |
Assign the value of integer 5 to the variable x |
Note : Note the difference between the assignment (=) and equal to (= =).