Select Chapter ❯
JavaScript Tutorial
Javascript Operators
Operators are used to perform some operations between variables.Javascript has different kind of operators for different purpose.
Arithmetic Operators
Arithmetic operators are those operators which are used to perform operations between generally numeric values.
Operator | Description |
---|---|
+ | It is called Addition Operator it is used to add two or more variables. For eg. var x + var y. |
- | It is called Subtraction Operator it is used to get the difference of the two or more variables. For eg. var x - var y. |
* | It is called Multiplication Operator it is used to get the product of two or more variables. For eg. var x * var y. |
/ | It is called Division Operator it is used to get the quotient of two or more variables. For eg. var x / var y. |
% | It is called Modulus Operator it is used to get the remainder of two or more variables. For eg. var x % var y. |
var x++ | It is called Post-Increment Operator it is used to return var x then increase the variable value by 1 |
var x-- | It is called Post-Decrement Operator it is used to return var x then decrease the variable value by 1 |
Assignment Operators
Assignment operators are those operators which are used to set values to a variables.
Operator | Description |
---|---|
var x=var y | It is used to to asign the values to the variable. For eg. var x=100; |
var x+=var y | It is same as var x=var x+var y |
var x-=var y | It is same as var x=var x-var y |
var x*=var y | It is same as var x=var x*var y |
var x/=var y | It is same as var x=var x/*var y |
var x%=var y | It is same as var x=var x%var y |
Comparison Operators
Cmparison operators are those operators which are used to compare two values.
Operator | Description |
---|---|
var x==var y | It is called Equal Operator it returns true if var x is equal to var y |
var x!=var y | It is called Not Equal Operator it returns true if var x is not equal to var y. |
> | It is called Greater Than Operator it returns true if var x is greater than var y. |
< | It is called Less Than Operator it returns true if var x is less than var y. |
>= | It is called Greater Than or Equal To Operator it returns true if var x is greater than or equal to var y. |
<= | It is called Less Than or Equal To Operator it returns true if var x is less than or equal to var y. |
Logical Operators
Logical operators are those operators which are used to combine conditional statements.
Operator | Description |
---|---|
var x and var y | It is same as var x && var y. It is called And Operator it returns true if var x and var y are true |
var x or var y | It is same as var x || var y. It is called Or Operator it returns true if one of then is true. |
!var x | It is called Not Operator it returns true if var x is not true. |