Operators in JavaScript

Operators in JavaScript #4

Do you know what are the operators in JavaScript? Operators are symbols that perform certain operations on one or more variables or values.

Mainly there are six types of operators in JavaScript.

  1. Arithmetic Operators
  2. Assignment Operators
  3. Comparison Operators
  4. Logical Operators
  5. Bitwise Operators
  6. Type Operators

Arithmetic Operators

Arithmetic operators perform arithmetic operations on numbers.

Operator SymbolDescription

Assignment Operators

Assignment operators are used to assign a values.

Operator SymbolDescription
=a = b
+=a += b
-=a -= b
*=a *= b
**=a **= b
/=a /= b
%=a %= b

Comparison Operators

Comparison operators are used to compare two values or variables.

Operator SymbolDescription
==equal to
===equal value and equal type
>greater than
<less than
>=greater than or equal to
<=less than or equal to
!=not equal
!==not equal value or not equal type
?ternary operator

Logical Operators

Operator SymbolDescription
&&logical and
||logical or
!logical not

Bitwise Operators

Operator SymbolDescriptionExample
&AND7 & 1
|OR7 | 1
~NOT~ 7
^XOR7 ^ 1
<<Zero fill left shift7 << 1
>>Signed right shift7 >> 1
>>>Zero fill right shift7 >>> 1

Type Operators

Operator SymbolDescription
typeofReturns the type of a variable
instanceofReturns true if an object is an instance of an object type

Previous Post: Var Let and Const in JavaScript

Leave a Reply

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

You May Also Like