An operator is a token that represents a particular operation to be performed on one or two operands. The combination of operands and operator is called an expression. The operation yields a result, which can be used as an operand in subsequent expressions. Expressions can be nested implicitly according to the precedence rules of the operators, or explicitly by using using the parentheses grouping operator.
Depending on the operators and operands used, side effects may occur. This is particularly likely when function calls are used as operands since a function call can invoke many lines of code.
For example, an expression calling two functions, each of which opens a pop-up browser window would cause two new windows to appear as a side effect every time the expression was evaluated.
Here is a list of all the operators supported by JavaScript:
Operator | Description |
---|---|
! | Logical NOT |
!= | NOT equal to |
% | Remainder |
%= | Remainder and assign to an LValue |
& | Bitwise AND |
&& | Logical AND |
&= | Bitwise AND and assign to an LValue |
( | Function argument delimiter and precedence control |
) | Function argument delimiter and precedence control |
* | Multiply |
*= | Multiply and assign to an LValue |
+ | Add |
+ | Concatenate string |
+ | Unary convert the operand to a numeric value. |
++ | Increment LValue |
+= | Add and assign to an LValue |
, | Argument delimiter |
- | Subtract |
- | Unary negate the value |
-- | Decrement LValue |
-= | Subtract and assign to an LValue |
. | Property accessor |
/ | Divide |
/= | Divide and assign to an LValue |
: | Part of conditional operator |
; | Empty statement |
< | Less than |
<< | Bitwise left shift |
<<= | Bitwise shift left and assign to an LValue |
<= | Less than or equal to |
= | Simple assignment to an LValue |
== | Equal to |
> | Greater than |
>= | Greater than or equal to |
>> | Bitwise shift right |
>>= | Bitwise shift right and assign to an LValue |
>>> | Bitwise shift right (unsigned) |
>>>= | Bitwise shift right (unsigned) and assign to an LValue |
? | Conditional operator |
[ | Array index delimiter |
] | Array index delimiter |
^ | Bitwise XOR (exclusive OR) |
^= | Bitwise exclusive XOR and assign to an LValue |
delete | Used to delete a property from an object if it can be deleted. |
false | Boolean constant |
new | Invokes an object constructor |
true | Boolean constant |
typeof | Determines the type of an evaluation or value. |
void | Regardless of the result of evaluating the expression that may be operated on, this will always yield the undefined value. |
{ | Start code block |
| | Bitwise inclusive OR |
|= | Bitwise inclusive OR and assign to an LValue |
|| | Logical OR |
} | End code block |
~ | Bitwise complement (NOT) |
Refer to the Operator Precedence topic for details of the order in which operators and their expressions are evaluated in complex lines of code. This is sometimes light-heartedly referred to as "who's on first".
Prev | Home | Next |
Opera | Up | Operator Precedence |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |