JavaScript Operators

JavaScript Operators


In this article we are goanna to see about what is JavaScript operators and how many types of operators and where we use these. which is most important when you are going to start your career in JavaScript. Please read and enjoy this article if you want to give any feedback about your experience, we welcome.




In JavaScript, an operator is a special symbol used to perform operations on operands (values and variables).

There are five types of Javascript operator which is more important we are goanna to focus on these.

Types of Operators:
  1. Arithmetic Operators
  2. Comparison (Relational) Operators
  3. Logical Operators
  4. Bitwise Operators
  5. Assignment Operators


JavaScript Arithmetic Operators:

Operator

Description

+

Addition

-

Subtraction

*

Multiplication

**

Exponentiation

/

Division

%

Modulus (Division Remainder)

++

Increment

--

Decrement


JavaScript Comparison Operators:


Operator

Description

==

equal to

===

equal value and equal type

!=

not equal

!==

not equal value or not equal type

> 

greater than

< 

less than

>=

greater than or equal to

<=

less than or equal to

?

ternary operator

Operator

Description

+

Addition

-

Subtraction

*

Multiplication

**

Exponentiation

/

Division

%

Modulus (Division Remainder)

++

Increment

--

Decrement

 
JavaScript Logical Operators:

Operator

Description

&&

logical and

||

logical or

!

logical not



JavaScript Bitwise Operators:

Operator

Description

Example

Same as

Result

Decimal

&

AND

5 & 1

0101 & 0001

0001

 1

|

OR

5 | 1

0101 | 0001

0101

 5

~

NOT

~ 5

 ~0101

1010

 10

^

XOR

5 ^ 1

0101 ^ 0001

0100

 4

<< 

Zero fill left shift

5 << 1

0101 << 1

1010

 10

>> 

Signed right shift

5 >> 1

0101 >> 1

0010

  2

>>> 

Zero fill right shift

5 >>> 1

0101 >>> 1

0010

  2



JavaScript Assignment Operators:

Operator

Example

Same As

=

x = y

x = y

+=

x += y

x = x + y

-=

x -= y

x = x - y

*=

x *= y

x = x * y

/=

x /= y

x = x / y

%=

x %= y

x = x % y

**=

x **= y

x = x ** y








Share:

0 comments

Please leave your comments...... Thanks