HTML and CSS Reference
In-Depth Information
Operators
Operators are symbols used to manipulate operands in an expression.
Operator Types
Table G-6 summarizes the JavaScript operator types.
Table G-6 Operator Types
Type
Operator
Name
Description
Example
Arithmetic
rtn 5 amt 1 5.6
1
-
Subtraction
Subtracts one operand from another
rtn 5 amt - disc
*
Multiplication
Multiplies one operand by another
rtn 5 amt * .5
/
Division
Divides one operand by another
rtn 5 amt / 4
%
Modulus
Returns the remainder of a division operation
rtn 5 amt % 3
11
Increment
Increases an operand by one
newAmt 5 11 oldAmt
newAmt 5 oldAmt 11
- -
Decrement
Decreases an operand by one
newAmt 5 - -oldAmt
newAmt 5 oldAmt- -
-
Negation
Returns the opposite value of an operand
newAmt 5 -oldAmt
Assignment
5
Assigns
Assigns the value of the right operand to the left
operand
discRate 5 4
15
Combines
Adds the value of the right operand to the value of
the left operand and assigns a new value to the left
operand
discRate 15 13
- 5
Subtracts
Subtracts the value of the right operand from the
value of the left operand and assigns a new value
to the left operand
discRate - 5 3
* 5
Multiplies
Multiplies the value of the right operand by the
value of the left operand and assigns a new value
to the left operand
discRate * 5 .2
/ 5
Divides
Divides the value of the left operand by the value
of the right operand and assigns a new value to the
left operand
discRate / 5 10
% 5
Modulus
Divides the value of the left operand by the value
of the right operand and assigns the remainder
(or zero) to the left operand
discRate % 5 5
Bitwise
~
Complement
Performs a binary NOT
secur 5 ~rights
<<
Shift left
Performs a binary shift left of the bits of an integer
Op 5 15 << 1
>>
Shift right
Performs a binary shift right of the bits of an integer
Op 5 15 >> 1
>>>
Shift right with zero
extension
Performs a binary unsigned shift right on an integer
Op 5 15 >>> 1
&
AND
Performs a bitwise AND on an integer
Op 5 01111 & 11111
^
XOR
Performs a bitwise XOR on an integer
Op 5 01111 ^ 11111
|
OR
Performs a bitwise OR on an integer
Op 5 01111 | 11111
Search WWH ::

Custom Search