Change Language


Follow Navioo On Twitter

>>

An assignment operator assigns a value to its left operand based on the value of its right operand.

Operators
Implemented in: JavaScript 1.0
ECMA Version: ECMA-262

The basic assignment operator is equal (=), which assigns the value of its right operand to its left operand. That is, x = y assigns the value of y to x. The other assignment operators are usually shorthand for standard operations, as shown in the following table.

Shorthand operator Meaning
x += y x = x + y
x -= y x = x - y
x *= y x = x * y
x /= y x = x / y
x %= y x = x % y
x <<= y x = x << y
x >>= y x = x >> y
x >>>= y x = x >>> y
x &= y x = x & y
x ^= y x = x ^ y
x |= y x = x | y

In unusual situations, the assignment operator is not identical to the Meaning expression in this table. When the left operand of an assignment operator itself contains an assignment operator, the left operand is evaluated only once. For example:

a[i++] += 5 //i is evaluated only once
a[i++] = a[i++] + 5 //i is evaluated twice
            

Syntax

valueA >> valueB

Example

text_javascript Navioo_docs

Ajax Javascript feed

↑ Grab this Headline Animator