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

23/02/2014 Categories: Javascript. No Comments on Operators in Javascript

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”

Suryateja Pericherla

Suryateja Pericherla

Hello, I am Suryateja Pericherla working as an Asst. Professor in CSE department at Vishnu Institute of Technology. I write articles to share my knowledge and make people knowledgeable regarding certain topics.
Suryateja Pericherla

Latest posts by Suryateja Pericherla (see all)

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

Scroll Up
Thank you for visiting startertutorials.com! If you like this website do share with your friends by clicking on the social icons available on the left hand side.

As the domain name is quite large to remember, use this short domain to visit this site. Short domain: stuts.me