What are the operators in JavaScript?

Operators in JavaScript are a number of symbols that use the JavaScript Language to send instructions for performing certain types of operations, including certain mathematical, relational and logical. And JavaScript displays the results of that specific task as directed.

How many types of Operators in JavaScript? And what?

There are basically 11 types of Operators in JavaScript, below is the list of Operators:

  1. Arithmetic Operators: (+, -, *, /,%, **)
  2. Operator to save any value in Assignment Operators or JavaScript Variable: (=)
  3. Bitwise Operators or Binary Operators in JavaScript: – (&, |, ^, ~, <<, >>, << =, >> =, >>> =, & =, ^ =, | =)
  4. Comparison Operators or Operators to Compare Two or More Values: – (==,! =, ===,! ==, <,>, <=,> =)
  5. Incrementing / Decrementing Operators or 1 Increase or Decrease Operator: – (++, – -)
  6. Logical Operators or Operators for making decisions based on multiple conditions: – (&&, ||,!)
  7. String Operators or Operators for pairing with one or more string: – (+)
  8. Type operators to check whether a JavaScript variable is an instance of a class operator : – (not space after :)( instanceof) or typeof Operator to check whether it is a type of a variable or value
  9. Ternery Operator or if..else Operator.
  10. delete Operator: or delete operator is used to delete a specific property of an object.
  11. in Operator: Used to find the specific property of the object.

What is Operand in JavaScript?

All the variables or values ​​on either side of the operator, in terms of JavaScript or any programming language, it is called Operand. Let us understand from the following example.

Here the two sides of the plus sign (+) are a and 5 respectively. These two operands and the plus sign (+) are the operators.

What is Operator Precedence?

Operator Precedence in JavaScript is a set of rules that determine which task will be performed first in JavaScript. Let us understand from the following example.

Explanation: The result of the above code will not be 18 but 16. The main reason for this is that among the two operators we use here, according to the Operator Precedence Rules, the multiplication (“*”) operator is given more priority than the addition (“+”) operator. Let’s look at another example below:

Explanation: Since the Parentheses “()” operator is given more priority than the Multiplication “*” operator in the above example, the work of addition between the parentheses is performed first. Then the function of multiplication “*” is performed.

What is Operator Associativity?

Operator Associativity is to determine which of the Operators of the same Precedence will be preferred in the absence of parentheses in JavaScript or any Programming Language.

How many types of Operator Associativity in JavaScript? And what?

There are two types of Operator Associativity in JavaScript:

  1. Right to Left (ie: Right Operator will be preferred.)
  2. Left to Right (ie: Left Operator will be preferred.)

Below is a list of JavaScript Operator Precedence. In the table below, Operator Precedence 1 priority will go down one by one. This list is very important to remember. Otherwise, if you try to solve various Mathematical and Programming problems, you may not get the desired results.

Table 1 operator precedence and associativity in JavaScript
OperatorOperator UseOperator AssociativityOperator Precedence
()Method/function call, groupingLeft to rightHighest — 1
[]Array accessLeft to right1
.Object property accessLeft to right1
++IncrementRight to left2
DecrementRight to left2
NegationRight to left2
!Logical NOTRight to left2
~Bitwise NOTRight to left2
deleteRemoves array value or object propertyRight to left2
newCreates an objectRight to left2
typeofReturns data typeRight to left2
voidSpecifies no value to returnRight to left2
/DivisionLeft to right3
*MultiplicationLeft to right3
%ModulusLeft to right3
+PlusLeft to right4
+String ConcatenationLeft to right4
SubtractionLeft to right4
>> Bitwise right-shiftLeft to right5
<< Bitwise left-shiftLeft to right5
>, >=Greater than, greater than or equal toLeft to right6
<, <=Less than, less than or equal toLeft to right6
==EqualityLeft to right7
!=InequalityLeft to right7
===Identity operator — equal to (and same data type)Left to right7
!==Non-identity operator — not equal to (or don’t have the same data type)Left to right7
&Bitwise ANDLeft to right8
^Bitwise XORLeft to right9
|Bitwise ORLeft to right10
&&Logical ANDLeft to right11
||Logical ORLeft to right12
?:Conditional branchLeft to right13
=AssignmentRight to left14
*=, /=, %=, +=,, -=, <<=, >>=, >>>=, &=, ^=, |=Assignment according to the preceding operatorRight to left14
,Multiple evaluationLeft to rightLowest: 15


Please enter your comment!
Please enter your name here