addition. AdditiveExpression : AdditiveExpression + MultiplicativeExpression 1. Let lref be the result of evaluating AdditiveExpression. 2. Let lval be ? GetValue(lref). 3. Let rref be the result of evaluating MultiplicativeExpression. 4. Let rval be ? GetValue(rref). 5. Let lprim be ? ToPrimitive(lval). 6. Let rprim be ? ToPrimitive(rval). 7. If Type(lprim) is String or Type(rprim) is String, then a. Let lstr be ? ToString(lprim). b. Let rstr be ? ToString(rprim). c. Return the String that is the result of concatenating lstr and rstr. 8. Let lnum be ? ToNumber(lprim). 9. Let rnum be ? ToNumber(rprim). 10. Return the result of applying the addition operation to lnum and rnum. See the Note below 12.8.5. NOTE 1 No hint is provided in the calls to ToPrimitive in steps 5 and 6. All standard objects except 12.8.3 The Addition Operator ( + ) 12.8.3.1 Runtime Semantics: Evaluation
addition. AdditiveExpression : AdditiveExpression + MultiplicativeExpression 1. Let lref be the result of evaluating AdditiveExpression. 2. Let lval be ? GetValue(lref). 3. Let rref be the result of evaluating MultiplicativeExpression. 4. Let rval be ? GetValue(rref). 5. Let lprim be ? ToPrimitive(lval). 6. Let rprim be ? ToPrimitive(rval). 7. If Type(lprim) is String or Type(rprim) is String, then a. Let lstr be ? ToString(lprim). b. Let rstr be ? ToString(rprim). c. Return the String that is the result of concatenating lstr and rstr. 8. Let lnum be ? ToNumber(lprim). 9. Let rnum be ? ToNumber(rprim). 10. Return the result of applying the addition operation to lnum and rnum. See the Note below 12.8.5. NOTE 1 No hint is provided in the calls to ToPrimitive in steps 5 and 6. All standard objects except 12.8.3 The Addition Operator ( + ) 12.8.3.1 Runtime Semantics: Evaluation
addition. AdditiveExpression : AdditiveExpression + MultiplicativeExpression 1. Let lref be the result of evaluating AdditiveExpression. 2. Let lval be ? GetValue(lref). 3. Let rref be the result of evaluating MultiplicativeExpression. 4. Let rval be ? GetValue(rref). 5. Let lprim be ? ToPrimitive(lval). 6. Let rprim be ? ToPrimitive(rval). 7. If Type(lprim) is String or Type(rprim) is String, then a. Let lstr be ? ToString(lprim). b. Let rstr be ? ToString(rprim). c. Return the String that is the result of concatenating lstr and rstr. 8. Let lnum be ? ToNumber(lprim). 9. Let rnum be ? ToNumber(rprim). 10. Return the result of applying the addition operation to lnum and rnum. See the Note below 12.8.5. NOTE 1 No hint is provided in the calls to ToPrimitive in steps 5 and 6. All standard objects except 12.8.3 The Addition Operator ( + ) 12.8.3.1 Runtime Semantics: Evaluation
ication to operate on references: 1. ReturnIfAbrupt(V). 2. If Type(V) is not Reference, return V. 3. Let base be GetBase(V). 4. If IsUnresolvableReference(V) is true, throw a ReferenceError exception. 5. If IsPropertyReference(V) is true, then a. If HasPrimitiveBase(V) is true, then i. Assert: In this case, base will never be unde ined or null. ii. Set base to ! ToObject(base). b. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). 6. Else base must be an Environment Record, a. Return ? base.GetBindingValue(GetReferencedName(V), IsStrictReference(V)) (see 8.1.1). NOTE The object that may be created in step 5.a.ii is not accessible outside of the above abstract operation and the ordinary object [[Get]] internal method. An implementation might 6.2.4.1 GetValue ( V )
ication to operate on references: 1. ReturnIfAbrupt(V). 2. If Type(V) is not Reference, return V. 3. Let base be GetBase(V). 4. If IsUnresolvableReference(V) is true, throw a ReferenceError exception. 5. If IsPropertyReference(V) is true, then a. If HasPrimitiveBase(V) is true, then i. Assert: In this case, base will never be unde ined or null. ii. Set base to ! ToObject(base). b. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). 6. Else base must be an Environment Record, a. Return ? base.GetBindingValue(GetReferencedName(V), IsStrictReference(V)) (see 8.1.1). NOTE The object that may be created in step 5.a.ii is not accessible outside of the above abstract operation and the ordinary object [[Get]] internal method. An implementation might 6.2.4.1 GetValue ( V )
addition. AdditiveExpression : AdditiveExpression + MultiplicativeExpression 1. Let lref be the result of evaluating AdditiveExpression. 2. Let lval be ? GetValue(lref). 3. Let rref be the result of evaluating MultiplicativeExpression. 4. Let rval be ? GetValue(rref). 5. Let lprim be ? ToPrimitive(lval). 6. Let rprim be ? ToPrimitive(rval). 7. If Type(lprim) is String or Type(rprim) is String, then a. Let lstr be ? ToString(lprim). b. Let rstr be ? ToString(rprim). c. Return the String that is the result of concatenating lstr and rstr. 8. Let lnum be ? ToNumber(lprim). 9. Let rnum be ? ToNumber(rprim). 10. Return the result of applying the addition operation to lnum and rnum. See the Note below 12.8.5. NOTE 1 No hint is provided in the calls to ToPrimitive in steps 5 and 6. All standard objects except 12.8.3 The Addition Operator ( + ) 12.8.3.1 Runtime Semantics: Evaluation
abstract operation ToPrimitive takes an input argument and an optional argument PreferredType. The abstract operation ToPrimitive converts its input argument to a non-Object type. If an object is capable of converting to more than one primitive type, it may use the optional hint PreferredType to favour that type. Conversion occurs according to the following algorithm: 1. Assert: input is an ECMAScript language value. 2. If Type(input) is Object, then a. If PreferredType was not passed, let hint be "default". b. Else if PreferredType is hint String, let hint be "string". c. Else PreferredType is hint Number, let hint be "number". 7.1.1 ToPrimitive ( input [ , PreferredType ] ) d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). e. If exoticToPrim is not unde ined, then i. Let result be ? Call(exoticToPrim, input, « hint »). ii. If Type(result) is not Object, return result. iii. Throw a TypeError exception. f. If hint is "default", set hint to "number". g. Return ? OrdinaryToPrimitive(input, hint). 3. Return input. NOTE When ToPrimitive is called with no hint, then it generally behaves as if the hint were
addition. AdditiveExpression : AdditiveExpression + MultiplicativeExpression 1. Let lref be the result of evaluating AdditiveExpression. 2. Let lval be ? GetValue(lref). 3. Let rref be the result of evaluating MultiplicativeExpression. 4. Let rval be ? GetValue(rref). 5. Let lprim be ? ToPrimitive(lval). 6. Let rprim be ? ToPrimitive(rval). 7. If Type(lprim) is String or Type(rprim) is String, then a. Let lstr be ? ToString(lprim). b. Let rstr be ? ToString(rprim). c. Return the String that is the result of concatenating lstr and rstr. 8. Let lnum be ? ToNumber(lprim). 9. Let rnum be ? ToNumber(rprim). 10. Return the result of applying the addition operation to lnum and rnum. See the Note below 12.8.5. NOTE 1 No hint is provided in the calls to ToPrimitive in steps 5 and 6. All standard objects except 12.8.3 The Addition Operator ( + ) 12.8.3.1 Runtime Semantics: Evaluation
type. UnaryExpression : + UnaryExpression 1. Let expr be the result of evaluating UnaryExpression. 2. Return ? ToNumber(? GetValue(expr)). NOTE The unary - operator converts its operand to Number type and then negates it. Negating +0 produces -0, and negating -0 produces +0. 12.5.6 Unary + Operator 12.5.6.1 Runtime Semantics: Evaluation 12.5.7 Unary - Operator 12.5.7.1 Runtime Semantics: Evaluation
type. UnaryExpression : + UnaryExpression 1. Let expr be the result of evaluating UnaryExpression. 2. Return ? ToNumber(? GetValue(expr)). NOTE The unary - operator converts its operand to Number type and then negates it. Negating +0 produces -0, and negating -0 produces +0. 12.5.6 Unary + Operator 12.5.6.1 Runtime Semantics: Evaluation 12.5.7 Unary - Operator 12.5.7.1 Runtime Semantics: Evaluation
type Number according to Table 10: Table 10: ToNumber Conversions Argument Type Result Unde ined Return NaN. Null Return +0. Boolean If argument is true, return 1. If argument is false, return +0. Number Return argument (no conversion). String See grammar and conversion algorithm below. Symbol Throw a TypeError exception. Object Apply the following steps: 1. Let primValue be ? ToPrimitive(argument, hint Number). 2. Return ? ToNumber(primValue). 7.1.3 ToNumber ( argument )