You are currently viewing What are the Types of Operators in Javascript | Full Guide

What are the Types of Operators in Javascript | Full Guide

Types of operators in JavaScript

In this article, we will see about what are the types of operators in javascript. Before we go into discussing JavaScript operators, let’s look at what is an expression.

What is an expression?

A valid combination of operators and operands is known as an expression, on evaluation, it yields results. An expression contains two elements, they are operators and operands.

Valid expression

Ex:

2+2 //4
2*2+2 //6

Here, ‘+’ and ‘*’ is an operator and ‘2’ is an operand. When we give this expression to the computer, the computer understands this expression and it evaluates this expression. The first expression performs the addition operation. Similarly, the second expression performs multiple and additional operations. Hence, both expressions are valid expressions.

Invalid Expression

Ex:

+ 2 2
* + 2 * + 2

In the above expression, When we give this type of expression the computer doesn’t understand, what to do with the expression and how this should be evaluated. Hence, both expressions are In-valid expressions. Because we have not given a valid combination of operators and operands. On the evaluation of this expression, we don’t get any results.

Operator

Operators in any programming language are broadly categorized into three types they are:

  1. Unitary Operators: accept only one operand
  2. Binary Operators: It accepts two operands. ex: *, %, -, +
  3. Ternary Operators: accept three operands. In javascript, only the “conditional operator” is a ternary.

Types of Javascript Operators

JS operators are categorized or divided into different types. You can easily remember JavaScript by remembering the shortcut “LARABICS“. Which means, ‘L’ Logical operator, ‘A’ Arithmetic operator, ‘R’ Relational operator, ‘A’ Assignment operator, ‘B’ Bitwise operator, ‘I’ Increment and Decrement operator, ‘C’ Conditional operator, and ‘S’ Special operator.

READ ALSO  What is Type Casting in JavaScript | Advanced Guide
Shortcut Operator Names Operators
L- Logical Operators &&, ||, !
A – Arithmetic Operators +, -, *, /, %
R – Relational Operators <, >, <=, >=, ==, !=, ===, !==
A – Assignment Operators =, SHA/AA : (+=, -=, /=)
B – Bitwise Operators &, |, ~, ^, <<, >>
I – Increment and Decrement Operators ++, —
C – Conditional Operators (condition ? if  true : if false)
S- Special Operators typeof, new, delete, comma etc.

Leave a Reply