JavaScript Operators and the Precedence Table



Navigation Aids -- This Page    Navigation Aids -- This Topic    Navigation Aids -- This Site








Review: Operator Evaluation within an Expression

There are general rules that determine the sequence of how operators will be evaluated in an expression:

  1. Arithmetic expressions (most expressions) are evaluated left-to-right when all operators of the expression have the same precedence.
  2. When operators in arithmetic expression have different precedence levels, then the operator with the higher precedence evaluates first, then the rest evaluate per rule (1) above.
  3. Non-arithmetic expressions will evaluate based on the precedence rule plus when more than one operator has the same precedence, then the operators evaluate based on their associativity rule.
  4. Operator evaluation sequence can be explicitly altered with the grouping operator.




About the JavaScript Operator Precedence Table

The purpose of this table is to describe the many JavaScript operators. The table serves as a precedence chart where operators are shown in diminishing order of precedence from top to bottom. The table acts as a driver table from which to link to additional detail for each operator. The table structure is defined here:

JavaScript Operator Chart in Order of Diminishing Precedence
Operator Operand Type Precedence Associativity JavaScript Example Operator Group
Symbol Type Name Left Right Prec Assoc
Footnotes: Examples of JavaScript expressions are available by clicking the orange literal "Pop Up".
binary dot operator object identifier 15 left Pop Up Access Group
[ ] binary bracket operator array integer 15 left Pop Up
( ) binary parentheses operator function argument 15 left Pop Up
new unary new operator constructor 15 right Pop Up
++ unary Post-increment lvalue 14 right Pop Up Postfix Group
-- unary Post-decrement lvalue 14 right Pop Up
++ unary Pre-increment lvalue 14 right Pop Up Prefix Group
-- unary Pre-decrement lvalue 14 right Pop Up
- unary unary minus operator number 14 right Pop Up Unary Plus & Minus
+ unary unary plus operator number 14 right No Operation
~ unary bitwise not operator integer 14 right Pop Up Unary Not Group
! unary logical not operator boolean 14 right Pop Up
delete unary delete operator lvalue 14 right Pop Up Unary Keyword Group
typeof unary typeof operator any 14 right Pop Up
void unary void operator any 14 right Pop Up
* binary multiplication operator number number 13 left Pop Up Multiplicative Operator Group
/ binary division operator number number 13 left Pop Up
% binary modulus operator number number 13 left Pop Up
+ binary addition operator number number 12 left Pop Up Additive Operator Group
string string
- binary subtraction operator number number 12 left Pop Up
<< binary left shift operator integer integer 11 left Pop Up Bitwise Shift Group
>> binary right shift operator integer integer 11 left Pop Up
>>> binary right shift zero fill operator integer integer 11 left Pop Up
<
and
<=
binary less than operators number
or
string
number
or
string
10 left Pop Up Relational Group
>
and
>=
binary greater than operators number
or
string
number
or
string
10 left Pop Up
instanceof binary instanceof operator object constructor 10 left Pop Up The IN Group
in binary in operator string object 10 left Pop Up
== binary equality operators any any 9 left Pop Up Equality Group
!=
=== binary identity operators any any 9 left Pop Up
!==
& binary bitwise AND operator integer integer 8 left Pop Up Bitwise Logical Group
^ binary bitwise XOR operator integer integer 7 left Pop Up
| binary bitwise OR operator integer integer 6 left Pop Up
&& binary logical AND operator boolean boolean 5 left Pop Up Logical Operator Group
|| binary logical OR operator boolean boolean 4 left Pop Up
? : ternary conditional operator boolean 2nd: any 3 left Pop Up N/A
3rd: any
= binary simple assignment operator lvalue any 2 right Pop Up Assignment Operator Group
*= binary compound assignment operators lvalue any 2 right Pop Up
/=
%=
+=
-=
<<=
>>=
>>>=
&=
^=
|=
, binary comma operator any any 1 left Pop Up N/A


Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson