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
  1. Return false.

1.3Static Semantics: IsValidSimpleAssignmentTarget

UpdateExpression:LeftHandSideExpression++ LeftHandSideExpression-- ++UnaryExpression --UnaryExpression
  1. Return false.

1.4Postfix Increment Operator

1.4.1Runtime Semantics: Evaluation

UpdateExpression:LeftHandSideExpression++
  1. Let lhs be the result of evaluating LeftHandSideExpression.
  2. Let oldValue be ? ToNumber(? GetValue(lhs)).
  3. Let newValue be the result of adding the value 1 to oldValue, using the same rules as for the + operator (see 12.8.5).
  4. Perform ? PutValue(lhs, newValue).
  5. Return oldValue.

1.5Postfix Decrement Operator

1.5.1Runtime Semantics: Evaluation

UpdateExpression:LeftHandSideExpression--
  1. Let lhs be the result of evaluating LeftHandSideExpression.
  2. Let oldValue be ? ToNumber(? GetValue(lhs)).
  3. Let newValue be the result of subtracting the value 1 from oldValue, using the same rules as for the - operator (12.8.5).
  4. Perform ? PutValue(lhs, newValue).
  5. Return oldValue.

1.6Prefix Increment Operator

1.6.1Runtime Semantics: Evaluation

UpdateExpression:++UnaryExpression
  1. Let expr be the result of evaluating UnaryExpression.
  2. Let oldValue be ? ToNumber(? GetValue(expr)).
  3. Let newValue be the result of adding the value 1 to oldValue, using the same rules as for the + operator (see 12.8.5).
  4. Perform ? PutValue(expr, newValue).
  5. Return newValue.

1.7Prefix Decrement Operator

1.7.1Runtime Semantics: Evaluation

UpdateExpression:--UnaryExpression
  1. Let expr be the result of evaluating UnaryExpression.
  2. Let oldValue be ? ToNumber(? GetValue(expr)).
  3. Let newValue be the result of subtracting the value 1 from oldValue, using the same rules as for the - operator (see 12.8.5).
  4. Perform ? PutValue(expr, newValue).
  5. Return newValue.

2Exponentiation Operator

Syntax

ExponentiationExpression[Yield]:UnaryExpression[?Yield] UpdateExpression[?Yield]**ExponentiationExpression[?Yield]

2.1Static Semantics: IsFunctionDefinition

ExponentiationExpression:UpdateExpression**ExponentiationExpression
  1. Return false.

2.2Static Semantics: IsValidSimpleAssignmentTarget

ExponentiationExpression:UpdateExpression**ExponentiationExpression
  1. Return false.

2.3Runtime Semantics: Evaluation

ExponentiationExpression:UpdateExpression**ExponentiationExpression
  1. Let left be the result of evaluating UpdateExpression.
  2. Let leftValue be ? GetValue(left).
  3. Let right be the result of evaluating ExponentiationExpression.
  4. Let rightValue be ? GetValue(right).
  5. Let base be ? ToNumber(leftValue).
  6. Let exponent be ? ToNumber(rightValue).
  7. 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
  1. Return false.

3.2Static Semantics: IsValidSimpleAssignmentTarget

UnaryExpression:UpdateExpression deleteUnaryExpression voidUnaryExpression typeofUnaryExpression +UnaryExpression -UnaryExpression ~UnaryExpression !UnaryExpression
  1. Return false.

4Applying the ** operator

Returns an implementation-dependent approximation of the result of raising base to the power exponent.

5Modifications to Existing Productions

5.1PostfixExpression

UpdateExpression

sec-update-expressions[Yield]:LeftHandSideExpression[?Yield] LeftHandSideExpression[?Yield][no LineTerminator here]++ LeftHandSideExpression[?Yield][no LineTerminator here]-- ++LeftHandSideExpression[?Yield] --LeftHandSideExpression[?Yield]

5.2UnaryExpression

UnaryExpression:PostfixExpression[?Yield] UpdateExpression[?Yield] deleteUnaryExpression[?Yield] voidUnaryExpression[?Yield] typeofUnaryExpression[?Yield] ++UnaryExpression[?Yield] --UnaryExpression[?Yield] +UnaryExpression[?Yield] -UnaryExpression[?Yield] ~UnaryExpression[?Yield] !UnaryExpression[?Yield]

5.3AssignmentOperator

AssignmentOperator:one of= *= /= %= += -= <<= >>= >>>= &= ^= |= = *= /= %= += -= <<= >>= >>>= &= ^= |= **= Note
The change here is the addition of **=.

5.4Punctuator

Punctuator::one of{ ( ) [ ] . ... ; , < > <= >= == != === !== + - * % ++ -- << >> >>> & | ^ ! ~ && || ? : = += -= *= %= <<= >>= >>>= &= |= ^= => { ( ) [ ] . ... ; , < > <= >= == != === !== + - * ** % ++ -- << >> >>> & | ^ ! ~ && || ? : = += -= *= **= %= <<= >>= >>>= &= |= ^= => Note
The change here is the addition of ** and **=.

AIntegration

  1. Math.pow is updated to reference "Applying the ** operator"
  2. All occurrences of PostfixExpression must be changed to UpdateExpression