Home >Web Front-end >JS Tutorial >Javascript Common Operators (Operators)-Javascript Basics Tutorial_Basic Knowledge
Operator | Operator Description | Example | Example | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Addition | x y |
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 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 |
Operator | Operator Description | Example | Example | ||||||||
== | 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 |
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 |