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.

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”