Microsoft® JScript
Operator Summary
Language Reference 

JScript has a full range of operators, including arithmetic, logical, bitwise, and assignment operators.

Computational Logical Bitwise Assignment
Description Symbol Description Symbol Description Symbol Description Symbol
Unary negation - Logical NOT ! Bitwise NOT ~ Assignment =
Increment ++ Less than < Bitwise Shift Left << Compound Assignment OP=
Decrement -- Greater than > Bitwise Shift Right >>    
Multiplication * Less than or equal to <= Unsigned Shift Right >>>    
Division / Greater than or equal to >= Bitwise AND &    
Modulo arithmetic % Equality == Bitwise XOR ^    
Addition + Inequality != Bitwise OR |    
Subtraction - Logical AND &&        
    Logical OR ||        
    Conditional (trinary) ?:        
    Comma ,        

Operator Precedence

Operators in JScript are evaluated in a particular order. This order is known as the operator precedence. The following table lists the operators in highest to lowest precedence order. Operators in the same row are evaluated in a left to right fashion.

OperatorDescription
. [] ()field access, array indexing, and function calls
++ -- - ~ ! typeof new voidunary operators, return data type, object creation, undefined values
* / %multiplication, division, modulo division
+ - +addition, subtraction, string concatenation
<< >> >>>bit shifting
< <= > >=less than, less than or equal, greater than, greater than or equal
== !=equality, inequality
&bitwise AND
^bitwise XOR
|bitwise OR
&&logical AND
||logical OR
?:conditional
= OP=assignment, assignment with operation
,multiple evaluation

Parentheses are used to alter the order of evaluation. The expression within the parentheses is fully evaluated before its value is used in the remainder of the statement.

An operator with higher precedence is evaluated before one with lower precedence. For example:

z = 78 * (96 + 3 + 45)

There are five operators in this expression: =, *, (), +, and +. According to precedence, they are evaluated in the following order: (), *, +, +, =. So, the sequence of evaluation goes as follows:

  1. Evaluate the expression within the ().
    1. There are two operators here, but they have the same precedence. So 96 and 3 are added and 45 added to that total, resulting in a value of 144.
  2. Multiplication is next, so 78 and 144 are multiplied, resulting in a value of 10998.
  3. Assignment is last, so 11232 is assigned into z.



© 1996 by Microsoft Corporation


Casa de Bender