Operators in javascript

JavaScript includes various categories of operators: Arithmetic operators, Comparison operators, Logical operators, Assignment operators, Conditional operators.

The task of the operator is to perform some operation on certain values(operands).

For example, 10 + 15,
where 10 and 15 are left and right operand and + is an operator.

Javascript has the following types of operators.

The above operators can be grouped into the following type of operators.

  • Unary operator and
  • Binary operator
  • Ternary operator(conditional operator).

Unary operator

Unary operator contains the single operand, either before or after the operator.

Before operator

operand operator

Example :

x++

After operator

operator operand

Example :

++x

Binary Operator

Binary operator contains the two operands, one before the operator and one after the operator.

operand1 operator operand2

Example :

1 + 2

Ternary operator (conditional)

Ternary operator is nothing but the short implementation of if else loop.

Ternary operator contains three operands. one operand is condition and two operands are values and it selected one of two values based on condition  

condition ? value1 : value2

if a condition is true, the operator has value1 otherwise value2.  


I hope you like this amazing Javascript Operator article.

You’ll also like: