13.4 Update Expressions
Syntax
UpdateExpression[Yield, Await] :
LeftHandSideExpression[?Yield, ?Await]
LeftHandSideExpression[?Yield, ?Await]
[no LineTerminator here]
++
LeftHandSideExpression[?Yield, ?Await]
[no LineTerminator here]
--
++
UnaryExpression[?Yield, ?Await]
--
UnaryExpression[?Yield, ?Await]
13.4.1 Static Semantics: Early Errors
UpdateExpression :
LeftHandSideExpression
++
LeftHandSideExpression
--
UpdateExpression :
++
UnaryExpression
--
UnaryExpression
13.4.2 Postfix Increment Operator
13.4.2.1 Runtime Semantics: Evaluation
UpdateExpression :
LeftHandSideExpression
++
- Let lhs be ? Evaluation of LeftHandSideExpression.
- Let oldValue be ? ToNumeric(? GetValue(lhs)).
- If oldValue is a Number, then
- Let newValue be Number::add(oldValue, 1𝔽).
- Else,
- Assert: oldValue is a BigInt.
- Let newValue be BigInt::add(oldValue, 1ℤ).
- Perform ? PutValue(lhs, newValue).
- Return oldValue.
13.4.3 Postfix Decrement Operator
13.4.3.1 Runtime Semantics: Evaluation
UpdateExpression :
LeftHandSideExpression
--
- Let lhs be ? Evaluation of LeftHandSideExpression.
- Let oldValue be ? ToNumeric(? GetValue(lhs)).
- If oldValue is a Number, then
- Let newValue be Number::subtract(oldValue, 1𝔽).
- Else,
- Assert: oldValue is a BigInt.
- Let newValue be BigInt::subtract(oldValue, 1ℤ).
- Perform ? PutValue(lhs, newValue).
- Return oldValue.
13.4.4 Prefix Increment Operator
13.4.4.1 Runtime Semantics: Evaluation
UpdateExpression :
++
UnaryExpression
- Let expr be ? Evaluation of UnaryExpression.
- Let oldValue be ? ToNumeric(? GetValue(expr)).
- If oldValue is a Number, then
- Let newValue be Number::add(oldValue, 1𝔽).
- Else,
- Assert: oldValue is a BigInt.
- Let newValue be BigInt::add(oldValue, 1ℤ).
- Perform ? PutValue(expr, newValue).
- Return newValue.
13.4.5 Prefix Decrement Operator
13.4.5.1 Runtime Semantics: Evaluation
UpdateExpression :
--
UnaryExpression
- Let expr be ? Evaluation of UnaryExpression.
- Let oldValue be ? ToNumeric(? GetValue(expr)).
- If oldValue is a Number, then
- Let newValue be Number::subtract(oldValue, 1𝔽).
- Else,
- Assert: oldValue is a BigInt.
- Let newValue be BigInt::subtract(oldValue, 1ℤ).
- Perform ? PutValue(expr, newValue).
- Return newValue.