Assignment operator (Definition)

An operator that causes an assignment as a by-product.

Availability:

ECMAScript edition - 2

Here is a table summarizing the assignment operators, most of which can be secondarily classified as members of other operator categories:

Value:Equivalent:Meaning:
=a = bSimple assignment to an LValue
+=a = a + bAdd and assign to an LValue
-=a = a - bSubtract and assign to an LValue
*=a = a * bMultiply and assign to an LValue
/=a = a / bDivide and assign to an LValue
%=a = a % bRemainder and assign to an LValue
&=a = a & bBitwise AND and assign to an LValue
|=a = a | bBitwise inclusive OR and assign to an LValue
^=a = a ^ bBitwise exclusive XOR and assign to an LValue
<<=a = a << bBitwise shift left and assign to an LValue
>>=a = a >> bBitwise shift right and assign to an LValue
>>>=a = a >>> bBitwise shift right (unsigned) and assign to an LValue
++a = a + 1Increment LValue
--a = 1 - 1Decrement LValue

Assignment operators include the simple assignment as well as the compound OP= form where OP is one of the shift, bitwise, multiplicative or additive operators.

Warnings:

See also:= (Assign), Add then assign (+=), Assignment expression, Bitwise AND then assign (&=), Bitwise OR then assign (|=), Bitwise shift left then assign (<<=), Bitwise shift right and assign (>>=), Bitwise unsigned shift right and assign (>>>=), Bitwise XOR and assign (^=), Concatenate then assign (+=), Divide then assign (/=), Multiply then assign (*=), Operator, Postfix expression, Prefix expression, Remainder then assign (%=), Subtract then assign (-=), var

Cross-references:

ECMA 262 edition 2 - section - 11.13

ECMA 262 edition 2 - section - 12.2

ECMA 262 edition 3 - section - 11.13

ECMA 262 edition 3 - section - 12.2

Wrox Instant JavaScript - page - 20