Stage 4 Draft / September 25, 2017
Exponentiation Operator
1Update Expressions
Syntax
UpdateExpression[Yield]:LeftHandSideExpression[?Yield]
LeftHandSideExpression[?Yield][no LineTerminator here]++
LeftHandSideExpression[?Yield][no LineTerminator here]--
++UnaryExpression[?Yield]
--UnaryExpression[?Yield]
1.1Static Semantics: Early Errors
UpdateExpression:LeftHandSideExpression++
LeftHandSideExpression--
UpdateExpression:++UnaryExpression
--UnaryExpression
1.2Static Semantics: IsFunctionDefinition
UpdateExpression:LeftHandSideExpression++
LeftHandSideExpression--
++UnaryExpression
--UnaryExpression
- Return false.
1.3Static Semantics: IsValidSimpleAssignmentTarget
UpdateExpression:LeftHandSideExpression++
LeftHandSideExpression--
++UnaryExpression
--UnaryExpression
- Return false.
1.4Postfix Increment Operator
1.4.1Runtime Semantics: Evaluation
UpdateExpression:LeftHandSideExpression++
- Let lhs be the result of evaluating LeftHandSideExpression.
- Let oldValue be ? ToNumber(? GetValue(lhs)).
- Let newValue be the result of adding the value
1
to oldValue, using the same rules as for the +
operator (see 12.8.5). - Perform ? PutValue(lhs, newValue).
- Return oldValue.
1.5Postfix Decrement Operator
1.5.1Runtime Semantics: Evaluation
UpdateExpression:LeftHandSideExpression--
- Let lhs be the result of evaluating LeftHandSideExpression.
- Let oldValue be ? ToNumber(? GetValue(lhs)).
- Let newValue be the result of subtracting the value
1
from oldValue, using the same rules as for the -
operator (12.8.5). - Perform ? PutValue(lhs, newValue).
- Return oldValue.
1.6Prefix Increment Operator
1.6.1Runtime Semantics: Evaluation
UpdateExpression:++UnaryExpression
- Let expr be the result of evaluating UnaryExpression.
- Let oldValue be ? ToNumber(? GetValue(expr)).
- Let newValue be the result of adding the value
1
to oldValue, using the same rules as for the +
operator (see 12.8.5). - Perform ? PutValue(expr, newValue).
- Return newValue.
1.7Prefix Decrement Operator
1.7.1Runtime Semantics: Evaluation
UpdateExpression:--UnaryExpression
- Let expr be the result of evaluating UnaryExpression.
- Let oldValue be ? ToNumber(? GetValue(expr)).
- Let newValue be the result of subtracting the value
1
from oldValue, using the same rules as for the -
operator (see 12.8.5). - Perform ? PutValue(expr, newValue).
- Return newValue.
2Exponentiation Operator
Syntax
ExponentiationExpression[Yield]:UnaryExpression[?Yield]
UpdateExpression[?Yield]**ExponentiationExpression[?Yield]
2.1Static Semantics: IsFunctionDefinition
ExponentiationExpression:UpdateExpression**ExponentiationExpression
- Return false.
2.2Static Semantics: IsValidSimpleAssignmentTarget
ExponentiationExpression:UpdateExpression**ExponentiationExpression
- Return false.
2.3Runtime Semantics: Evaluation
ExponentiationExpression:UpdateExpression**ExponentiationExpression
- Let left be the result of evaluating UpdateExpression.
- Let leftValue be ? GetValue(left).
- Let right be the result of evaluating ExponentiationExpression.
- Let rightValue be ? GetValue(right).
- Let base be ? ToNumber(leftValue).
- Let exponent be ? ToNumber(rightValue).
- Return the result of Applying the ** operator with base and exponent as specified in 4.
3Unary Operators
Syntax
UnaryExpression[Yield]:UpdateExpression[?Yield]
deleteUnaryExpression[?Yield]
voidUnaryExpression[?Yield]
typeofUnaryExpression[?Yield]
+UnaryExpression[?Yield]
-UnaryExpression[?Yield]
~UnaryExpression[?Yield]
!UnaryExpression[?Yield]
3.1Static Semantics: IsFunctionDefinition
UnaryExpression:UpdateExpression
deleteUnaryExpression
voidUnaryExpression
typeofUnaryExpression
+UnaryExpression
-UnaryExpression
~UnaryExpression
!UnaryExpression
- Return false.
3.2Static Semantics: IsValidSimpleAssignmentTarget
UnaryExpression:UpdateExpression
deleteUnaryExpression
voidUnaryExpression
typeofUnaryExpression
+UnaryExpression
-UnaryExpression
~UnaryExpression
!UnaryExpression
- Return false.
4Applying the ** operator
Returns an implementation-dependent approximation of the result of raising base to the power exponent.
- If exponent is NaN, the result is NaN.
- If exponent is +0, the result is 1, even if base is NaN.
- If exponent is −0, the result is 1, even if base is NaN.
- If base is NaN and exponent is nonzero, the result is NaN.
- If abs(base) > 1 and exponent is +∞, the result is +∞.
- If abs(base) > 1 and exponent is −∞, the result is +0.
- If abs(base) is 1 and exponent is +∞, the result is NaN.
- If abs(base) is 1 and exponent is −∞, the result is NaN.
- If abs(base) < 1 and exponent is +∞, the result is +0.
- If abs(base) < 1 and exponent is −∞, the result is +∞.
- If base is +∞ and exponent > 0, the result is +∞.
- If base is +∞ and exponent < 0, the result is +0.
- If base is −∞ and exponent > 0 and exponent is an odd integer, the result is −∞.
- If base is −∞ and exponent > 0 and exponent is not an odd integer, the result is +∞.
- If base is −∞ and exponent < 0 and exponent is an odd integer, the result is −0.
- If base is −∞ and exponent < 0 and exponent is not an odd integer, the result is +0.
- If base is +0 and exponent > 0, the result is +0.
- If base is +0 and exponent < 0, the result is +∞.
- If base is −0 and exponent > 0 and exponent is an odd integer, the result is −0.
- If base is −0 and exponent > 0 and exponent is not an odd integer, the result is +0.
- If base is −0 and exponent < 0 and exponent is an odd integer, the result is −∞.
- If base is −0 and exponent < 0 and exponent is not an odd integer, the result is +∞.
- If base < 0 and base is finite and exponent is finite and exponent is not an integer, the result is NaN.
5Modifications to Existing Productions
5.1PostfixExpression
sec-update-expressions[Yield]:LeftHandSideExpression[?Yield]
LeftHandSideExpression[?Yield][no LineTerminator here]++
LeftHandSideExpression[?Yield][no LineTerminator here]--
++LeftHandSideExpression[?Yield]
--LeftHandSideExpression[?Yield]
UnaryExpression:PostfixExpression[?Yield]
UpdateExpression[?Yield]
deleteUnaryExpression[?Yield]
voidUnaryExpression[?Yield]
typeofUnaryExpression[?Yield]
++UnaryExpression[?Yield]
--UnaryExpression[?Yield]
+UnaryExpression[?Yield]
-UnaryExpression[?Yield]
~UnaryExpression[?Yield]
!UnaryExpression[?Yield]
AssignmentOperator:one of= *= /= %= += -= <<= >>= >>>= &= ^= |=
= *= /= %= += -= <<= >>= >>>= &= ^= |= **=
Note
The change here is the addition of **=
.
Punctuator::one of{ ( ) [ ] . ... ; , < > <= >= == != === !== + - * % ++ -- << >> >>> & | ^ ! ~ && || ? : = += -= *= %= <<= >>= >>>= &= |= ^= =>
{ ( ) [ ] . ... ; , < > <= >= == != === !== + - * ** % ++ -- << >> >>> & | ^ ! ~ && || ? : = += -= *= **= %= <<= >>= >>>= &= |= ^= =>
Note
The change here is the addition of **
and **=
.
AIntegration
- Math.pow is updated to reference "Applying the ** operator"
- All occurrences of PostfixExpression must be changed to UpdateExpression