Operator (Definition)

A special symbolic token that when placed adjacent to or between values creates an expression.

Availability:

ECMAScript edition - 2

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:

OperatorDescription
!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
deleteUsed to delete a property from an object if it can be deleted.
falseBoolean constant
newInvokes an object constructor
trueBoolean constant
typeofDetermines the type of an evaluation or value.
voidRegardless 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".

See also:Additive operator, Assignment operator, Associativity, Binary operator, Bitwise operator, Cast operator, Equality operator, Expression, Grouping operator ( ), Lexical element, Logical operator, Mathematics, Multiplicative operator, Operator Precedence, Postfix operator, Prefix operator, Punctuator, typeof, Unary operator, void

Cross-references:

ECMA 262 edition 2 - section - 11

ECMA 262 edition 3 - section - 11