Availability: |
| ||||||||
Property/method value type: | Depends on right value | ||||||||
JavaScript syntax: | - | anLValue = anExpression | |||||||
Argument list: | anExpression | Some operation that yields a suitable value to assign | |||||||
anLValue | A target that can be assigned to |
The expression value on the right is assigned to the target operand on the left.
The associativity is right to left.
Refer to the operator precedence topic for details of execution order.
The source expression to the right is called an RValue, the target expression to the left is called an LValue. The LValue must be capable of having something assigned to it and the RVlaue must evaluate to a meaningful and compatible value or a run time exception will be thrown.
The operand to the left of the operator must be an LValue. That is, it should be able to take an assignment and store the value.
Be careful not to confuse the single equals with the double equals. Placing a double equals in place of an assignment will do a comparison without assigning the result. This is less dangerous than mistakenly assigning a value where you intended to compare for equality. The interpreter may be forgiving enough that a run time error isn't generated, but the side effects could be subtle and make it hard to diagnose the cause.
ECMA 262 edition 2 - section - 10.1.3
ECMA 262 edition 2 - section - 11.1.2
ECMA 262 edition 2 - section - 11.13
ECMA 262 edition 2 - section - 12.2
ECMA 262 edition 3 - section - 10.1.3
ECMA 262 edition 3 - section - 11.1.2
ECMA 262 edition 3 - section - 11.13
ECMA 262 edition 3 - section - 12.2
Prev | Home | Next |
ASP | Up | Assignment expression |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |