Posted By:
26 Aug, 2014 11:45 am PDT

Operators in JavaScript

Please tell about the mathematical operators in JavaScript with the help of an example.



What is an operator?

Simple answer can be given using expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and + is called operator. JavaScript language supports following type of operators.

  • Arithmetic Operators
  • Comparision Operators
  • Logical (or Relational) Operators
  • Assignment Operators
  • Conditional (or ternary) Operators

The Arithmatic Operators:

There are following arithmatic operators supported by JavaScript language:

Assume variable A holds 10 and variable B holds 20 then:





Adds two operands

A + B will give 30


Subtracts second operand from the first

A - B will give -10


Multiply both operands

A * B will give 200


Divide numerator by denumerator

B / A will give 2


Modulus Operator and remainder of after an integer division

B % A will give 0


Increment operator, increases integer value by one

A++ will give 11


Decrement operator, decreases integer value by one

A-- will give 9

Note: Addition operator (+) works for Numeric as well as Strings. e.g. "a" + 10 will give "a10".

Was it useful?  

Please login to reply to this problem.