July 1998
Intermediate to advanced
1456 pages
65h 5m
English
+= — NN 2 IE J1 ECMA 1
The add-by-value operator. This class of operator combines a regular
assignment operator (=) with one of the many other
operators to carry out the assignment by performing the stated
operation on the left operand with the value of the right operand.
For example, if a variable named a has a string
stored in it, you can append a string to a with
the += operator:
a += " and some more."
Without the add-by-value operator, the operation had to be structured as follows:
a = a + " and some more"
Table 11.2 shows all the assignment operators that function this way:
Table 11-2. Assignment Operators
|
Operator |
Example |
Equivalent |
|---|---|---|
+= |
a += b |
a = a + b |
-= |
a -= b |
a = a - b |
*= |
a *= b |
a = a * b |
/= |
a /= b |
a = a / b |
%= |
a %= b |
a = a % b |
<<= |
a <<= b |
a = a << b |
>>= |
a >>= b |
a = a >> b |
>>>= |
a >>>= b |
a = a >>> b |
&= |
a &= b |
a = a & b |
|= |
a |= b |
a = a | b |
^= |
a ^= b |
a = a ^ b |
output += "<H1>Section 2</H1>" total *= .95
Read now
Unlock full access