Operators in JavaScript:

Operators in JavaScript are very similar to operators that appear in other programming languages. In algebra the “+” operator is used to do addition.

Here is list of operators which is supported by JavaScript:

  • Arithmetic Operators
  • Comparison Operators
  • Logical or Relational Operators
  • Assignment Operators
  • Conditional Operators

Arithmetic Operators in JavaScript:

JavaScript Arithmetic Operators are used to perform arithmetic operations between variables and/or values.

Following Arithmetic Operators are supported by JavaScript

Operator Description Example

(Assume that x=30 and y=10)

+ Addition x + y = 40
Subtraction x – y = 20
* Multiplication x * y = 300
/ Division x / y = 3
% Modulus x % y = 0
++x Pre Increment ++x = 30
X++ Post Increment x ++ = 40
–y Pre Decrement –y = 10
y– Post Decrement y– = 9

Comparison Operators in JavaScript:

JavaScript Comparison Operators are used to compare values in JavaScript.
Following Comparison Operators are supported by JavaScript

Operator Description Example(Assume that x=30 and y=10) Result
== Equal x == y Not true or false
=== Identical x===y True
!= Not Equal x!=y True
<> Not Equal x<>y True
!== Not Identical x!==y False
> Greater Than x > y True
< Less Than x < y False
>= Greater Than or Equal x >= y True
<= Less Than or Equal x <= y False

Logical Operators in JavaScript:

In JavaScript Logical Operators are used to specify the logic between operands.

Following Logical Operators are supported by JavaScript

Operator Description Example(Assume that x=30 and y=10) Result
&& Logical And(if both variables are non zero than true) x && y True
|| Logical Or(if any variables are non zero than true) X || y True
! Logical Not x ! y True

Assignment Operators in JavaScript:

JavaScript Assignment Operators are used to assign values to JavaScript variables.

Following Assignment Operators are supported by JavaScript

Operator Description Example

(Assume that x=30 and y=10)

= Assignment x = 30 and y = 10
+= Addition x = x+ y (x=40)
-= Subtraction x = x- y (x =20)
*= Multiplication x = x * y (x=300)
/= Division x = x / y (x=3)
%= Modulus x = x % y (x=0)

Conditional Operator in JavaScript:

Conditional operator is also known as “Miscellaneous Operator”. In JavaScript there is only one conditional operator.

Operator Description Example
?: Conditional expression If condition is true ? then value x ootherwise value y.

Leave a Reply

Your email address will not be published. Required fields are marked *