JavaScript expressions use special symbols called operators to perform
arithmetic and string manipulation. This appendix explains what the various
operators do, as well as operator precedence (which operator is used first).

You obtain the result of this expression by treating operand1,
operand2, and the result as sets of 32 bits. Each bit of the result is
the corresponding bits of operand1 and operand2 ANDed together.
The result of AND on two bits is 1 if both bits are 1, and 0 otherwise.

Example:

var tmp = 79 & 31;

In this example, operand1 is 79 (00000000000000000000000001001111) and
operand2 is 31 (00000000000000000000000000011111). tmp is set to 15
(00000000000000000000000000001111).

The bitwise exclusive-or (XOR) operator is a binary operator. The syntax is

operand1 ^ operand2

You obtain the result of this expression by treating operand1,
operand2, and the result as sets of 32 bits. Each bit of the result is
the corresponding bits of operand1 and operand2 XORed together.
The result of XOR on two bits is 1 if only one of the bits is 1, and 0 if both
bits are identical.

Example:

var tmp = 79 ^ 96;

In this example, operand1 is 79 (00000000000000000000000001001111) and
operand2 is 96 (00000000000000000000000001100000). tmp is set to 47
(00000000000000000000000000101111).

You obtain the result of this expression by treating operand1,
operand2, and the result as sets of 32 bits. Each bit of the result is
the corresponding bits of operand1 and operand2 ORed together. The
result of OR on two bits is 1 if either bit is 1, and 0 if both bits are 0.

Example:

var tmp = 79 | 96;

In this example, operand1 is 79 (00000000000000000000000001001111) and
operand2 is 96 (00000000000000000000000001100000). tmp is set to 111
(00000000000000000000000001101111).

The value of this expression depends on operand1. If operand1
evaluates as true, the value is operand2. Otherwise, the value is
operand3.

Example:

var tmp = (x == 1) ? 7.2 : foo();

In this example, operand1 is (x == 1), operand2 is 7.2, and
operand3 is foo(). If operand1 is true (x is equal to 1), tmp is
set to operand2 (7.2). If operand1 is false (x is not equal to 1),
tmp is set to operand3 (the return value of foo()).

The value of this expression is the remainder of performing an integer
division of operand1 by operand2. operand2 cannot be equal
to 0. The absolute value of the result will be less than the absolute value of
operand2, and the sign of the result will be the same as the sign of
operand1.

Example:

var tmp = 12.1 % 3.7

In this example, operand1 is 12.1 and operand2 is 3.7. tmp is
set to the remainder of dividing operand1 divided by operand2.
12.1 divided by 3.7 is 3 with a remainder of 1, so tmp is set to 1.

You obtain the result of the expression by treating operand1 as a set
of 32 bits and shifting the bits left by the value in operand2.
High-order bits are discarded, and the low-order bits are filled with 0's.

Example:

var tmp = 31 << 3;

In this example, operand1 is 31 (00000000000000000000000000011111) and
operand2 is 3. tmp is set to 248 (00000000000000000000000011111000).

You obtain the result of the expression by treating operand1 as a set
of 32 bits and shifting the bits right by the value in operand2.
High-order bits are copied from the highest-order bit (which dictates the sign
of the value, hence sign-propagating), and low-order bits are discarded.

Example:

var tmp = -9 >> 2;

In this example, operand1 is -9 (11111111111111111111111111110111) and
operand2 is 2. tmp is set to -3 (11111111111111111111111111111101).

The value of this expression is the value of operand1opoperand2, where op can be addition (+), bitwise and (&),
bitwise exclusive-or (^), bitwise or (|), division (/), modulo (%),
multiplication (*), shift left (<<), sign-propagating shift right
(>>), subtraction(-), or zero-fill shift right (>>>). As a side
effect, operand1 is also assigned the result of operand1opoperand1. This is equivalent to:

operand1 = operand1opoperand2

Example:

tmp += 2;

In this example, operand1 is tmp, op is +, and operand2
is 2. operand2 (2) is added to operand1 (tmp).

You obtain the result of the expression by treating operand1 as a set
of 32 bits and shifting the bits right by the value in operand2.
High-order bits are filled with 0's (hence zero-fill), and low-order bits are
discarded.

Example:

var tmp = -9 >>> 2;

In this example, operand1 is -9 (11111111111111111111111111110111) and
operand2 is 2. tmp is set to 1,073,741,821
(00111111111111111111111111111101).