Advanced Java and Web Technologies for JNTUK
Blog providing beginner tutorials on different web technologies like HTML, CSS, Javascript, PHP, MYSQL, XML, Java Beans, Servlets, JSP and AJAX
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Categories: Javascript. No Comments on Operators in Javascript
0
(0)

In this article we will learn about importance of operators and different categories of operators in JavaScript.

 

Introduction

 


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


JavaScript supports most of the traditional operators, which are grouped depending on their functionality, as follows:

  • Arithmetic Operators
  • Assignment Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators 

 

Arithmetic Operators

 

Following are the arithmetic operators in JavaScript:

 

+

*

/

%

++

– (unary)

+ (unary)

 

 

Assignment Operators

 

Following are the assignment operators in JavaScript:

 

+=

-=

*=

/=

%=

<<=

>>=

>>>=

&=

|=

^=

 

 

Relational Operators

 

Following are the relational operators in JavaScript:

 

Operator Operation
= = Equal to
! = Not equal to
< Less than
< = Less than or equal to
> Greater than
> = Greater than or equal to
= = = Is strictly equal to
! = = Is strictly not equal to

 

The = = = and ! = = relational operators considers the type of the operands while evaluating the expression.

 

Logical Operators

 

Following are the logical operators in JavaScript:

 

&&

||

!

 

 

Bitwise Operators

 

Following are the bitwise operators in JavaScript:

 

&

|

^

~

<<

>>

>>>

 

 

Operator precedence

 

Below table summarizes the operator precedence and associativity for all the operators in JavaScript:

 

Operators

Precedence Level

Associativity

. (dot), [ ], new, ( ), ++, — 1 Left to right
++, — 2 Right to left
+ (unary), – (unary), ~, !, delete, typeof, void 3 Right to left
*, /, % 4 Left to right
+, – 5 Left to right
<<, >>, >>> 6 Left to right
<, <=, >, >=, instanceof, in 7 Left to right
==, !=, ===, !== 8 Left to right
& 9 Left to right
^ 10 Left to right
| 11 Left to right
&& 12 Left to right
|| 13 Left to right
?: 14 Right to left
=, *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^= |= 15 Right to left
, (comma) 16 Left to right

 

 

String Concatenation Operator

 

Unlike C, strings in JavaScript are not stored or treated as arrays. Strings in JavaScript are unit scalar values. Two strings can be concatenated with each other using the + operator. For example, if a variable first holds the string value “Java” then the result of the following expression will be JavaScript:

first + “Script”

 

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.

Leave a Reply

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