Advanced Java and Web Technologies Tutorial
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.
AJWT » Javascript » Operators in Javascript
Suryateja Pericherla Categories: Javascript. No Comments on Operators in Javascript
Join Our Newsletter - Tips, Contests and Other Updates
Email
Name

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

 

This article is a part of our advanced java and web technologies tutorial.

 

Introduction

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:

OperatorOperation
= =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, ( ), ++, —1Left to right
++, —2Right to left
+ (unary), – (unary), ~, !, delete, typeof, void3Right to left
*, /, %4Left to right
+, –5Left to right
<<, >>, >>>6Left to right
<, <=, >, >=, instanceof, in7Left to right
==, !=, ===, !==8Left to right
&9Left to right
^10Left to right
|11Left to right
&&12Left to right
||13Left to right
?:14Right to left
=, *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^= |=15Right to left
, (comma)16Left 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”

 

Next let’s learn about type conversion in JavaScript.

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?

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 *

Facebook
Twitter
Pinterest
Youtube
Instagram