These operations are not a part of the ECMAScript language; they are defined here to solely to aid the specification of the semantics of the ECMAScript language. Other, more specialized abstract operations are defined throughout this specification.
The ECMAScript language implicitly performs automatic type conversion as needed. To clarify the semantics of certain constructs it is useful to define a set of conversion abstract operations. The conversion abstract operations are polymorphic; they can accept a value of any ECMAScript language type or of a Completion Record value. But no other specification types are used with these operations.
The abstract operation ToPrimitive takes an input argument and an optional argument PreferredType. The abstract operation ToPrimitive converts its input argument to a nonObject 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 Table 9:
Input Type  Result 

Completion Record  If input is an abrupt completion, return input. Otherwise return ToPrimitive(input.[[value]]) also passing the optional hint PreferredType. 
Undefined  Return input. 
Null  Return input. 
Boolean  Return input. 
Number  Return input. 
String  Return input. 
Symbol  Return input. 
Object  Perform the steps following this table. 
When Type(input) is Object, the following steps are taken:
"default"
."string"
."number"
."default"
, let hint be "number"
.When the abstract operation OrdinaryToPrimitive is called with arguments O and hint, the following steps are taken:
"string"
or "number"
."string"
, then
"toString"
, "valueOf"
»."valueOf"
, "toString"
».NOTE When ToPrimitive is called with no hint, then it generally behaves as if the hint were Number. However, objects may override this behaviour by defining a @@toPrimitive method. Of the objects defined in this specification only Date objects (see 20.3.4.45) and Symbol objects (see 19.4.3.4) override the default ToPrimitive behaviour. Date objects treat no hint as if the hint were String.
The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 10:
Argument Type  Result 

Completion Record  If argument is an abrupt completion, return argument. Otherwise return ToBoolean(argument.[[value]]). 
Undefined  Return false. 
Null  Return false. 
Boolean  Return argument. 
Number  Return false if argument is +0, −0, or NaN; otherwise return true. 
String  Return false if argument is the empty String (its length is zero); otherwise return true. 
Symbol  Return true. 
Object  Return true. 
The abstract operation ToNumber converts argument to a value of type Number according to Table 11:
Argument Type  Result 

Completion Record  If argument is an abrupt completion, return argument. Otherwise return ToNumber(argument.[[value]]). 
Undefined  Return NaN. 
Null  Return +0. 
Boolean  Return 1 if argument is true. Return +0 if argument is false. 
Number  Return argument (no conversion). 
String  See grammar and conversion algorithm below. 
Symbol  Throw a TypeError exception. 
Object 
Apply the following steps:

ToNumber applied to Strings applies the following grammar to the input String interpreted as a sequence of UTF16 encoded code points (6.1.4). If the grammar cannot interpret the String as an expansion of StringNumericLiteral, then the result of ToNumber is NaN.
NOTE 1 The terminal symbols of this grammar are all composed of Unicode BMP code points so the result will be NaN if the string contains the UTF16 encoding of any supplementary code points or any unpaired surrogate code points.
+
StrUnsignedDecimalLiteral
StrUnsignedDecimalLiteral.
DecimalDigits_{opt} ExponentPart_{opt}.
DecimalDigits ExponentPart_{opt}0
1
2
3
4
5
6
7
8
9
e
E
+
DecimalDigits
DecimalDigitsAll grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric literals (11.8.3)
NOTE 2 Some differences should be noted between the syntax of a StringNumericLiteral and a NumericLiteral (see 11.8.3):
A StringNumericLiteral may include leading and/or trailing white space and/or line terminators.
A StringNumericLiteral that is decimal may have any number of leading 0
digits.
A StringNumericLiteral that is decimal may include a +
or 
to indicate its sign.
A StringNumericLiteral that is empty or contains only white space is converted to +0.
Infinity
and –Infinity
are recognized as a StringNumericLiteral but not as a NumericLiteral.
The conversion of a String to a Number value is similar overall to the determination of the Number value for a numeric literal (see 11.8.3), but some of the details are different, so the process for converting a String numeric literal to a value of Number type is given here. This value is determined in two steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in 11.8.3.1.
The MV of StringNumericLiteral ::: [empty] is 0.
The MV of StringNumericLiteral ::: StrWhiteSpace is 0.
The MV of StringNumericLiteral ::: StrWhiteSpace_{opt} StrNumericLiteral StrWhiteSpace_{opt} is the MV of StrNumericLiteral, no matter whether white space is present or not.
The MV of StrNumericLiteral ::: StrDecimalLiteral is the MV of StrDecimalLiteral.
The MV of StrNumericLiteral ::: BinaryIntegerLiteral is the MV of BinaryIntegerLiteral.
The MV of StrNumericLiteral ::: OctalIntegerLiteral is the MV of OctalIntegerLiteral.
The MV of StrNumericLiteral ::: HexIntegerLiteral is the MV of HexIntegerLiteral.
The MV of StrDecimalLiteral ::: StrUnsignedDecimalLiteral is the MV of StrUnsignedDecimalLiteral.
The MV of StrDecimalLiteral ::: +
StrUnsignedDecimalLiteral is the MV of StrUnsignedDecimalLiteral.
The MV of StrDecimalLiteral ::: 
StrUnsignedDecimalLiteral is the negative of the MV of StrUnsignedDecimalLiteral. (Note that if the MV of StrUnsignedDecimalLiteral is 0, the negative of this MV is also 0. The rounding rule described
below handles the conversion of this signless mathematical zero to a floatingpoint +0 or −0 as
appropriate.)
The MV of StrUnsignedDecimalLiteral ::: Infinity is 10^{10000} (a value so large that it will round to +∞).
The MV of StrUnsignedDecimalLiteral ::: DecimalDigits .
is the MV of DecimalDigits.
The MV of StrUnsignedDecimalLiteral ::: DecimalDigits .
DecimalDigits is the MV of
the first DecimalDigits plus (the MV of the second DecimalDigits
times 10^{−n}), where n is the
number of code points in the second DecimalDigits.
The MV of StrUnsignedDecimalLiteral ::: DecimalDigits .
ExponentPart is the MV of
DecimalDigits times 10^{e}, where e is the MV of ExponentPart.
The MV of StrUnsignedDecimalLiteral ::: DecimalDigits .
DecimalDigits ExponentPart is (the MV of the first DecimalDigits plus (the MV of the second
DecimalDigits times 10^{−n})) times 10^{e}, where n is the number
of code points in the second DecimalDigits and e is the MV of ExponentPart.
The MV of StrUnsignedDecimalLiteral ::: .
DecimalDigits is the MV of DecimalDigits times
10^{−n}, where n is the number of code points in DecimalDigits.
The MV of StrUnsignedDecimalLiteral ::: .
DecimalDigits ExponentPart is the MV of
DecimalDigits times 10^{e−n}, where n is the number of code points in
DecimalDigits and e is the MV of ExponentPart.
The MV of StrUnsignedDecimalLiteral ::: DecimalDigits is the MV of DecimalDigits.
The MV of StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart is the MV of DecimalDigits times 10^{e}, where e is the MV of ExponentPart.
Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type.
If the MV is 0, then the rounded value is +0 unless the first non white space code point in the String numeric literal
is ‘
’, in which case the rounded value is −0. Otherwise, the rounded value must be the
Number value for the MV (in the sense defined in 6.1.6), unless
the literal includes a StrUnsignedDecimalLiteral and the literal has more than 20 significant
digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each
significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each
significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is
significant if it is not part of an ExponentPart and
0
; orThe abstract operation ToInteger converts argument to an integral numeric value. This abstract operation functions as follows:
The abstract operation ToInt32 converts argument to one of 2^{32} integer values in the range −2^{31} through 2^{31}−1, inclusive. This abstract operation functions as follows:
NOTE Given the above definition of ToInt32:
The ToInt32 abstract operation is idempotent: if applied to a result that it produced, the second application leaves that value unchanged.
ToInt32(ToUint32(x)) is equal to ToInt32(x) for all values of x. (It is to preserve this latter property that +∞ and −∞ are mapped to +0.)
ToInt32 maps −0 to +0.
The abstract operation ToUint32 converts argument to one of 2^{32} integer values in the range 0 through 2^{32}−1, inclusive. This abstract operation functions as follows:
NOTE Given the above definition of ToUint32:
Step 6 is the only difference between ToUint32 and ToInt32.
The ToUint32 abstract operation is idempotent: if applied to a result that it produced, the second application leaves that value unchanged.
ToUint32(ToInt32(x)) is equal to ToUint32(x) for all values of x. (It is to preserve this latter property that +∞ and −∞ are mapped to +0.)
ToUint32 maps −0 to +0.
The abstract operation ToInt16 converts argument to one of 2^{16} integer values in the range −32768 through 32767, inclusive. This abstract operation functions as follows:
The abstract operation ToUint16 converts argument to one of 2^{16} integer values in the range 0 through 2^{16}−1, inclusive. This abstract operation functions as follows:
NOTE Given the above definition of ToUint16:
The abstract operation ToInt8 converts argument to one of 2^{8} integer values in the range −128 through 127, inclusive. This abstract operation functions as follows:
The abstract operation ToUint8 converts argument to one of 2^{8} integer values in the range 0 through 255, inclusive. This abstract operation functions as follows:
The abstract operation ToUint8Clamp converts argument to one of 2^{8} integer values in the range 0 through 255, inclusive. This abstract operation functions as follows:
NOTE Unlike the other ECMAScript integer conversion abstract operation, ToUint8Clamp rounds
rather than truncates noninteger values and does not convert +∞ to 0. ToUint8Clamp does “round half to
even” tiebreaking. This differs from Math.round
which does “round
half up” tiebreaking.
The abstract operation ToString converts argument to a value of type String according to Table 12:
Argument Type  Result 

Completion Record  If argument is an abrupt completion, return argument. Otherwise return ToString(argument.[[value]]). 
Undefined  Return "undefined" . 
Null  Return "null" . 
Boolean 
If argument is true, return If argument is false, return 
Number  See 7.1.12.1. 
String  Return argument. 
Symbol  Throw a TypeError exception. 
Object 
Apply the following steps: 1. Let primValue be ToPrimitive(argument, hint String). 2. Return ToString(primValue). 
The abstract operation ToString converts a Number m to String format as follows:
"NaN"
."0"
.""
and ToString(−m)."Infinity"
.NOTE 1 The following observations may be useful as guidelines for implementations, but are not part of the normative requirements of this Standard:
NOTE 2 For implementations that provide more accurate conversions than required by the rules above, it is recommended that the following alternative version of step 5 be used as a guideline:
5. Otherwise, let n, k, and s be integers such that k ≥ 1, 10^{k−1} ≤ s < 10^{k}, the Number value for s × 10^{n−k} is m, and k is as small as possible. If there are multiple possibilities for s, choose the value of s for which s × 10^{n−k} is closest in value to m. If there are two such possible values of s, choose the one that is even. Note that k is the number of digits in the decimal representation of s and that s is not divisible by 10.
NOTE 3 Implementers of ECMAScript may find useful the paper and code written by David M. Gay for binarytodecimal conversion of floatingpoint numbers:
Gay, David M. Correctly Rounded BinaryDecimal and DecimalBinary Conversions. Numerical Analysis, Manuscript 9010.
AT&T Bell Laboratories (Murray Hill, New Jersey). November 30, 1990. Available as
http://cm.belllabs.com/cm/cs/doc/90/410.ps.gz. Associated
code available as
http://netlib.sandia.gov/fp/dtoa.c and as
http://netlib.sandia.gov/fp/g_fmt.c and may also be found at the various
netlib
mirror sites.
The abstract operation ToObject converts argument to a value of type Object according to Table 13:
Argument Type  Result 

Completion Record  If argument is an abrupt completion, return argument. Otherwise return ToObject(argument.[[value]]). 
Undefined  Throw a TypeError exception. 
Null  Throw a TypeError exception. 
Boolean  Return a new Boolean object whose [[BooleanData]] internal slot is set to the value of argument. See 19.3 for a description of Boolean objects. 
Number  Return a new Number object whose [[NumberData]] internal slot is set to the value of argument. See 20.1 for a description of Number objects. 
String  Return a new String object whose [[StringData]] internal slot is set to the value of argument. See 21.1 for a description of String objects. 
Symbol  Return a new Symbol object whose [[SymbolData]] internal slot is set to the value of argument. See 19.4 for a description of Symbol objects. 
Object  Return argument. 
The abstract operation ToPropertyKey converts argument to a value that can be used as a property key by performing the following steps:
The abstract operation ToLength converts argument to an integer suitable for use as the length of an arraylike object. It performs the following steps:
The abstract operation CanonicalNumericIndexString returns argument converted to a
numeric value if it is a String representation of a Number that would be produced by ToString,
or the string "0"
. Otherwise, it returns undefined. This abstract operation
functions as follows:
"0"
, return −0.A canonical numeric string is any String value for which the CanonicalNumericIndexString abstract operation does not return undefined.
The abstract operation RequireObjectCoercible throws an error if argument is a value that cannot be converted to an Object using ToObject. It is defined by Table 14:
Argument Type  Result 

Completion Record  If argument is an abrupt completion, return argument. Otherwise return RequireObjectCoercible(argument.[[value]]). 
Undefined  Throw a TypeError exception. 
Null  Throw a TypeError exception. 
Boolean  Return argument. 
Number  Return argument. 
String  Return argument. 
Symbol  Return argument. 
Object  Return argument. 
The abstract operation IsArray takes one argument argument, and performs the following steps:
The abstract operation IsCallable determines if argument, which must be an ECMAScript language value or a Completion Record, is a callable function with a [[Call]] internal method.
The abstract operation IsConstructor determines if argument, which must be an ECMAScript language value or a Completion Record, is a function object with a [[Construct]] internal method.
The abstract operation IsExtensible is used to determine whether additional properties can be added to the object that is O. A Boolean value is returned. This abstract operation performs the following steps:
The abstract operation IsInteger determines if argument is a finite integer numeric value.
The abstract operation IsPropertyKey determines if argument, which must be an ECMAScript language value or a Completion Record, is a value that may be used as a property key.
The abstract operation IsRegExp with argument argument performs the following steps:
The internal comparison abstract operation SameValue(x, y), where x and y are ECMAScript language values, produces true or false. Such a comparison is performed as follows:
NOTE This algorithm differs from the Strict Equality Comparison Algorithm (7.2.13) in its treatment of signed zeroes and NaNs.
The internal comparison abstract operation SameValueZero(x, y), where x and y are ECMAScript language values, produces true or false. Such a comparison is performed as follows:
NOTE SameValueZero differs from SameValue only in its treatment of +0 and −0.
The comparison x < y, where x and y are values, produces true, false, or undefined (which indicates that at least one operand is NaN). In addition to x and y the algorithm takes a Boolean flag named LeftFirst as a parameter. The flag is used to control the order in which operations with potentially visible sideeffects are performed upon x and y. It is necessary because ECMAScript specifies left to right evaluation of expressions. The default value of LeftFirst is true and indicates that the x parameter corresponds to an expression that occurs to the left of the y parameter’s corresponding expression. If LeftFirst is false, the reverse is the case and operations must be performed upon y before x. Such a comparison is performed as follows:
NOTE 1 Step 5 differs from step 11 in the algorithm for the addition operator +
(12.7.3) in using “and” instead of “or”.
NOTE 2 The comparison of Strings uses a simple lexicographic ordering on sequences of code unit values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and collating order defined in the Unicode specification. Therefore String values that are canonically equal according to the Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalized form. Also, note that for strings containing supplementary characters, lexicographic ordering on sequences of UTF16 code unit values differs from that on sequences of code point values.
The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:
The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:
NOTE This algorithm differs from the SameValue Algorithm (7.2.9) in its treatment of signed zeroes and NaNs.
The abstract operation Get is used to retrieve the value of a specific property of an object. The operation is called with arguments O and P where O is the object and P is the property key. This abstract operation performs the following steps:
The abstract operation GetV is used to retrieve the value of a specific property of an ECMAScript language value. If the value is not an object, the property lookup is performed using a wrapper object appropriate for the type of the value. The operation is called with arguments V and P where V is the value and P is the property key. This abstract operation performs the following steps:
The abstract operation Set is used to set the value of a specific property of an object. The operation is called with arguments O, P, V, and Throw where O is the object, P is the property key, V is the new value for the property and Throw is a Boolean flag. This abstract operation performs the following steps:
The abstract operation CreateDataProperty is used to create a new own property of an object. The operation is called with arguments O, P, and V where O is the object, P is the property key, and V is the value for the property. This abstract operation performs the following steps:
NOTE This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false.
The abstract operation CreateMethodProperty is used to create a new own property of an object. The operation is called with arguments O, P, and V where O is the object, P is the property key, and V is the value for the property. This abstract operation performs the following steps:
NOTE This abstract operation creates a property whose attributes are set to the same defaults used for builtin methods and methods defined using class declaration syntax. Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false.
The abstract operation CreateDataPropertyOrThrow is used to create a new own property of an object. It throws a TypeError exception if the requested property update cannot be performed. The operation is called with arguments O, P, and V where O is the object, P is the property key, and V is the value for the property. This abstract operation performs the following steps:
NOTE This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false causing this operation to throw a TypeError exception.
The abstract operation DefinePropertyOrThrow is used to call the [[DefineOwnProperty]] internal method of an object in a manner that will throw a TypeError exception if the requested property update cannot be performed. The operation is called with arguments O, P, and desc where O is the object, P is the property key, and desc is the Property Descriptor for the property. This abstract operation performs the following steps:
The abstract operation DeletePropertyOrThrow is used to remove a specific own property of an object. It throws an exception if the property is not configurable. The operation is called with arguments O and P where O is the object and P is the property key. This abstract operation performs the following steps:
The abstract operation GetMethod is used to get the value of a specific property of an object when the value of the property is expected to be a function. The operation is called with arguments O and P where O is the object, P is the property key. This abstract operation performs the following steps:
The abstract operation HasProperty is used to determine whether an object has a property with the specified property key. The property may be either an own or inherited. A Boolean value is returned. The operation is called with arguments O and P where O is the object and P is the property key. This abstract operation performs the following steps:
The abstract operation HasOwnProperty is used to determine whether an object has an own property with the specified property key. A Boolean value is returned. The operation is called with arguments O and P where O is the object and P is the property key. This abstract operation performs the following steps:
The abstract operation Call is used to call the [[Call]] internal method of a function object. The operation is called with arguments F, V , and optionally argumentsList where F is the function object, V is an ECMAScript language value that is the this value of the [[Call]], and argumentsList is the value passed to the corresponding argument of the internal method. If argumentsList is not present, an empty List is used as its value. This abstract operation performs the following steps:
The abstract operation Construct is used to call the [[Construct]] internal method of a function object. The operation is called with arguments F, and optionally argumentsList, and newTarget where F is the function object. argumentsList and newTarget are the values to be passed as the corresponding arguments of the internal method. If argumentsList is not present, an empty List is used as its value. If newTarget is not present, F is used as its value. This abstract operation performs the following steps:
NOTE If newTarget is not passed, this operation is equivalent to: new
F(...argumentsList)
The abstract operation SetIntegrityLevel is used to fix the set of own properties of an object. This abstract operation performs the following steps:
"sealed"
or
"frozen"
."sealed"
, then
"frozen"
,
The abstract operation TestIntegrityLevel is used to determine if the set of own properties of an object are fixed. This abstract operation performs the following steps:
"sealed"
or
"frozen"
."frozen"
and IsDataDescriptor(currentDesc) is true, then
The abstract operation CreateArrayFromList is used to create an Array object whose elements are provided by a List. This abstract operation performs the following steps:
The abstract operation CreateListFromArrayLike is used to create a List value whose elements are provided by the indexed properties of an arraylike object, obj. The optional argument elementTypes is a List containing the names of ECMAScript Language Types that are allowed for element values of the List that is created. This abstract operation performs the following steps:
"length"
)).The abstract operation Invoke is used to call a method property of an object. The operation is called with arguments O, P , and optionally argumentsList where O serves as both the lookup point for the property and the this value of the call, P is the property key, and argumentsList is the list of arguments values passed to the method. If argumentsList is not present, an empty List is used as its value. This abstract operation performs the following steps:
The abstract operation OrdinaryHasInstance implements the default algorithm for determining if an object O inherits from the instance object inheritance path provided by constructor C. This abstract operation performs the following steps:
"prototype"
).null
, return false.The abstract operation SpeciesConstructor is used to retrieve the constructor that should be used to create new objects that are derived from the argument object O. The defaultConstructor argument is the constructor to use if a constructor @@species property cannot be found starting from O. This abstract operation performs the following steps:
"constructor"
).When the abstract operation EnumerableOwnNames is called with Object O the following steps are taken:
NOTE The order of elements in the returned list is the same as the enumeration order that is used by a forin statement.
The abstract operation GetFunctionRealm with argument obj performs the following steps:
NOTE Step 5 will only be reached if target is a nonstandard exotic function object that does not have a [[Realm]] internal slot.
The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
The abstract operation IteratorNext with argument iterator and optional argument value performs the following steps:
"next"
, «
»)."next"
,
«value»).The abstract operation IteratorComplete with argument iterResult performs the following steps:
The abstract operation IteratorValue with argument iterResult performs the following steps:
The abstract operation IteratorStep with argument iterator requests the next value from iterator and returns either false indicating that the iterator has reached its end or the IteratorResult object if a next value is available. IteratorStep performs the following steps:
The abstract operation IteratorClose with arguments iterator and completion is used to notify an iterator that it should perform any actions it would normally perform when it has reached its completed state:
"return"
).The abstract operation CreateIterResultObject with arguments value and done creates an object that supports the IteratorResult interface by performing the following steps:
"value"
, value)."done"
, done).The abstract operation CreateListIterator with argument list creates an Iterator (25.1.1.2) object whose next method returns the successive elements of list. It performs the following steps:
next
(7.4.8.1)."next"
,
next).The ListIterator next
method is a standard builtin function object (clause 17) that performs the following steps:
NOTE A ListIterator next
method will throw an exception if applied to any object
other than the one with which it was originally associated.