18 The Global Object

The unique global object is created before control enters any execution context.

The global object does not have a [[Construct]] internal method; it is not possible to use the global object as a constructor with the new operator.

The global object does not have a [[Call]] internal method; it is not possible to invoke the global object as a function.

The value of the [[Prototype]] internal slot of the global object is implementation-dependent.

In addition to the properties defined in this specification the global object may have additional host defined properties. This may include a property whose value is the global object itself; for example, in the HTML document object model the window property of the global object is the global object itself.

18.1 Value Properties of the Global Object

18.1.1 Infinity

The value of Infinity is +∞ (see 6.1.6). This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

18.1.2 NaN

The value of NaN is NaN (see 6.1.6). This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

18.1.3 undefined

The value of undefined is undefined (see 6.1.1). This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

18.2 Function Properties of the Global Object

18.2.1 eval (x)

The eval function is the %eval% intrinsic object. When the eval function is called with one argument x, the following steps are taken:

  1. Let evalRealm be the value of the active function object's [[Realm]] internal slot.
  2. Let strictCaller be false.
  3. Let directEval be false.
  4. Return PerformEval(x, evalRealm, strictCaller, directEval).

18.2.1.1 Runtime Semantics: PerformEval( x, evalRealm, strictCaller, direct)

The abstract operation PerformEval with arguments x, evalRealm, strictCaller, and direct performs the following steps:

  1. Assert: If direct is false then strictCaller is also false.
  2. If Type(x) is not String, return x.
  3. Let script be the ECMAScript code that is the result of parsing x, interpreted as UTF-16 encoded Unicode text as described in 6.1.4, for the goal symbol Script. If the parse fails or any early errors are detected, throw a SyntaxError exception (but see also clause 16).
  4. If script Contains ScriptBody is false, return undefined.
  5. Let body be the ScriptBody of script.
  6. If strictCaller is true, let strictEval be true.
  7. Else, let strictEval be IsStrict of script.
  8. Let ctx be the running execution context. If direct is true ctx will be the execution context that performed the direct eval. If direct is false ctx will be the execution context for the invocation of the eval function.
  9. If direct is true, then
    1. Let lexEnv be NewDeclarativeEnvironment(ctx’s LexicalEnvironment).
    2. Let varEnv be ctx’s VariableEnvironment.
  10. Else,
    1. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[globalEnv]]).
    2. Let varEnv be evalRealm.[[globalEnv]].
  11. If strictEval is true, let varEnv be lexEnv.
  12. If ctx is not already suspended, Suspend ctx.
  13. Let evalCxt be a new ECMAScript code execution context.
  14. Set the evalCxt’s Realm to evalRealm.
  15. Set the evalCxt’s VariableEnvironment to varEnv.
  16. Set the evalCxt’s LexicalEnvironment to lexEnv.
  17. Push evalCxt on to the execution context stack; evalCxt is now the running execution context.
  18. Let result be EvalDeclarationInstantiation(body, varEnv, lexEnv, strictEval).
  19. If result.[[type]] is normal, then
    1. Let result be the result of evaluating body.
  20. If result.[[type]] is normal and result.[[value]] is empty, then
    1. Let result be NormalCompletion(undefined).
  21. Suspend evalCxt and remove it from the execution context stack.
  22. Resume the context that is now on the top of the execution context stack as the running execution context.
  23. Return Completion(result).

NOTE The eval code cannot instantiate variable or function bindings in the variable environment of the calling context that invoked the eval if the calling context is evaluating formal parameter initializers or if either the code of the calling context or the eval code is strict code. Instead such bindings are instantiated in a new VariableEnvironment that is only accessible to the eval code. Bindings introduced by let, const, or class declarations are always instantiated in a new LexicalEnvironment.

18.2.1.2 Runtime Semantics: EvalDeclarationInstantiation( body, varEnv, lexEnv, strict)

When the abstract operation EvalDeclarationInstantiation is called with arguments body, varEnv, lexEnv, and strict the following steps are taken:

  1. Let varNames be the VarDeclaredNames of body.
  2. Let varDeclarations be the VarScopedDeclarations of body.
  3. Let lexEnvRec be lexEnv's EnvironmentRecord.
  4. Let varEnvRec be varEnv's EnvironmentRecord.
  5. If strict is false, then
    1. If varEnvRec is a global Environment Record, then
      1. For each name in varNames, do
        1. If varEnvRec.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
        2. NOTE: eval will not create a global var declaration that would be shadowed by a global lexical declaration.
    2. Let thisLex be lexEnv.
    3. Assert: the following loop will terminate.
    4. Repeat while thisLex is not the same as varEnv,
      1. Let thisEnvRec be thisLex's EnvironmentRecord.
      2. If thisEnvRec is not an object Environment Record, then
        1. NOTE: The environment of with statements cannot contain any lexical declaration so it doesn’t need to be checked for var/let hoisting conflicts.
        2. For each name in varNames, do
          1. If thisEnvRec.HasBinding(name) is true, then
            1. Throw a SyntaxError exception.
          2. NOTE: A direct eval will not hoist var declaration over a like-named lexical declaration.
      3. Let thisLex be thisLex's outer environment reference.
  6. Let functionsToInitialize be an empty List.
  7. Let declaredFunctionNames be an empty List.
  8. For each d in varDeclarations, in reverse list order do
    1. If d is neither a VariableDeclaration or a ForBinding, then
      1. Assert: d is either a FunctionDeclaration or a GeneratorDeclaration.
      2. NOTE If there are multiple FunctionDeclarations for the same name, the last declaration is used.
      3. Let fn be the sole element of the BoundNames of d.
      4. If fn is not an element of declaredFunctionNames, then
        1. If varEnvRec is a global Environment Record, then
          1. Let fnDefinable be varEnvRec.CanDeclareGlobalFunction(fn).
          2. ReturnIfAbrupt(fnDefinable).
          3. If fnDefinable is false, throw SyntaxError exception.
        2. Append fn to declaredFunctionNames.
        3. Insert d as the first element of functionsToInitialize.
  9. Let declaredVarNames be an empty List.
  10. For each d in varDeclarations, do
    1. If d is a VariableDeclaration or a ForBinding, then
      1. For each String vn in the BoundNames of d, do
        1. If vn is not an element of declaredFunctionNames, then
          1. If varEnvRec is a global Environment Record, then
            1. Let vnDefinable be varEnvRec.CanDeclareGlobalVar(vn).
            2. ReturnIfAbrupt(vnDefinable).
            3. If vnDefinable is false, throw SyntaxError exception.
          2. If vn is not an element of declaredVarNames, then
            1. Append vn to declaredVarNames.
  11. NOTE: No abnormal terminations occur after this algorithm step unless varEnvRec is a global Environment Record and the global object is a Proxy exotic object.
  12. Let lexDeclarations be the LexicallyScopedDeclarations of body.
  13. For each element d in lexDeclarations do
    1. NOTE Lexically declared names are only instantiated here but not initialized.
    2. For each element dn of the BoundNames of d do
      1. If IsConstantDeclaration of d is true, then
        1. Let status be lexEnvRec.CreateImmutableBinding(dn, true).
      2. Else,
        1. Let status be lexEnvRec.CreateMutableBinding(dn, false).
      3. ReturnIfAbrupt(status).
  14. For each production f in functionsToInitialize, do
    1. Let fn be the sole element of the BoundNames of f.
    2. Let fo be the result of performing InstantiateFunctionObject for f with argument lexEnv.
    3. If varEnvRec is a global Environment Record, then
      1. Let status be varEnvRec.CreateGlobalFunctionBinding(fn, fo, true).
      2. ReturnIfAbrupt(status).
    4. Else,
      1. Let bindingExists be varEnvRec.HasBinding(fn).
      2. If bindingExists is false, then
        1. Let status be varEnvRec.CreateMutableBinding(fn, true).
        2. Assert: status is not an abrupt completion because of validation preceding step 12.
        3. Let status be varEnvRec.InitializeBinding(fn, fo).
      3. Else,
        1. Let status be varEnvRec.SetMutableBinding(fn, fo, false).
      4. Assert: status is not an abrupt completion.
  15. For each String vn in declaredVarNames, in list order do
    1. If varEnvRec is a global Environment Record, then
      1. Let status be varEnvRec.CreateGlobalVarBinding(vn, true).
      2. ReturnIfAbrupt(status).
    2. Else,
      1. Let bindingExists be varEnvRec.HasBinding(vn).
      2. If bindingExists is false, then
        1. Let status be varEnvRec.CreateMutableBinding(vn, true).
        2. Assert: status is not an abrupt completion because of validation preceding step 12.
        3. Let status be varEnvRec.InitializeBinding(vn, undefined).
        4. Assert: status is not an abrupt completion.
  16. Return NormalCompletion(empty)

NOTE An alternative version of this algorithm is described in B.3.5.

18.2.2 isFinite (number)

The isFinite function is the %isFinite% intrinsic object. When the isFinite function is called with one argument x, the following steps are taken:

  1. Let num be ToNumber(number).
  2. ReturnIfAbrupt(num).
  3. If num is NaN, +∞, or −∞, return false.
  4. Otherwise, return true.

18.2.3 isNaN (number)

The isNaN function is the %isNaN% intrinsic object. When the isNaN function is called with one argument number, the following steps are taken:

  1. Let num be ToNumber(number).
  2. ReturnIfAbrupt(num).
  3. If num is NaN, return true.
  4. Otherwise, return false.

NOTE A reliable way for ECMAScript code to test if a value X is a NaN is an expression of the form X !== X. The result will be true if and only if X is a NaN.

18.2.4 parseFloat (string)

The parseFloat function produces a Number value dictated by interpretation of the contents of the string argument as a decimal literal.

The parseFloat function is the %parseFloat% intrinsic object. When the parseFloat function is called with one argument string, the following steps are taken:

  1. Let inputString be ToString(string).
  2. ReturnIfAbrupt(inputString).
  3. Let trimmedString be a substring of inputString consisting of the leftmost code unit that is not a StrWhiteSpaceChar and all code units to the right of that code unit. (In other words, remove leading white space.) If inputString does not contain any such code units, let trimmedString be the empty string.
  4. If neither trimmedString nor any prefix of trimmedString satisfies the syntax of a StrDecimalLiteral (see 7.1.3.1), return NaN.
  5. Let numberString be the longest prefix of trimmedString, which might be trimmedString itself, that satisfies the syntax of a StrDecimalLiteral.
  6. Let mathFloat be MV of numberString.
  7. If mathFloat=0, then
    1. If the first code unit of trimmedString is "-", return −0.
    2. Return +0.
  8. Return the Number value for mathFloat.

NOTE parseFloat may interpret only a leading portion of string as a Number value; it ignores any code units that cannot be interpreted as part of the notation of an decimal literal, and no indication is given that any such code units were ignored.

18.2.5 parseInt (string , radix)

The parseInt function produces an integer value dictated by interpretation of the contents of the string argument according to the specified radix. Leading white space in string is ignored. If radix is undefined or 0, it is assumed to be 10 except when the number begins with the code unit pairs 0x or 0X, in which case a radix of 16 is assumed. If radix is 16, the number may also optionally begin with the code unit pairs 0x or 0X.

The parseInt function is the %parseInt% intrinsic object. When the parseInt function is called, the following steps are taken:

  1. Let inputString be ToString(string).
  2. ReturnIfAbrupt(string).
  3. Let S be a newly created substring of inputString consisting of the first code unit that is not a StrWhiteSpaceChar and all code units following that code unit. (In other words, remove leading white space.) If inputString does not contain any such code unit, let S be the empty string.
  4. Let sign be 1.
  5. If S is not empty and the first code unit of S is 0x002D (HYPHEN-MINUS), let sign be −1.
  6. If S is not empty and the first code unit of S is 0x002B (PLUS SIGN) or 0x002D (HYPHEN-MINUS), remove the first code unit from S.
  7. Let R = ToInt32(radix).
  8. ReturnIfAbrupt(R).
  9. Let stripPrefix be true.
  10. If R ≠ 0, then
    1. If R < 2 or R > 36, return NaN.
    2. If R ≠ 16, let stripPrefix be false.
  11. Else R = 0,
    1. Let R = 10.
  12. If stripPrefix is true, then
    1. If the length of S is at least 2 and the first two code units of S are either "0x" or "0X", remove the first two code units from S and let R = 16.
  13. If S contains a code unit that is not a radix-R digit, let Z be the substring of S consisting of all code units before the first such code unit; otherwise, let Z be S.
  14. If Z is empty, return NaN.
  15. Let mathInt be the mathematical integer value that is represented by Z in radix-R notation, using the letters A-Z and a-z for digits with values 10 through 35. (However, if R is 10 and Z contains more than 20 significant digits, every significant digit after the 20th may be replaced by a 0 digit, at the option of the implementation; and if R is not 2, 4, 8, 10, 16, or 32, then mathInt may be an implementation-dependent approximation to the mathematical integer value that is represented by Z in radix-R notation.)
  16. If mathInt = 0, then
    1. If sign = −1, return −0.
    2. Return +0.
  17. Let number be the Number value for mathInt.
  18. Return sign × number.

NOTE parseInt may interpret only a leading portion of string as an integer value; it ignores any code units that cannot be interpreted as part of the notation of an integer, and no indication is given that any such code units were ignored.

18.2.6 URI Handling Functions

Uniform Resource Identifiers, or URIs, are Strings that identify resources (e.g. web pages or files) and transport protocols by which to access them (e.g. HTTP or FTP) on the Internet. The ECMAScript language itself does not provide any support for using URIs except for functions that encode and decode URIs as described in 18.2.6.2, 18.2.6.3, 18.2.6.4 and 18.2.6.5

NOTE Many implementations of ECMAScript provide additional functions and methods that manipulate web pages; these functions are beyond the scope of this standard.

18.2.6.1 URI Syntax and Semantics

A URI is composed of a sequence of components separated by component separators. The general form is:

        Scheme : First / Second ; Third ? Fourth

where the italicized names represent components and “:”, “/”, “;” and “?” are reserved for use as separators. The encodeURI and decodeURI functions are intended to work with complete URIs; they assume that any reserved code units in the URI are intended to have special meaning and so are not encoded. The encodeURIComponent and decodeURIComponent functions are intended to work with the individual component parts of a URI; they assume that any reserved code units represent text and so must be encoded so that they are not interpreted as reserved code units when the component is part of a complete URI.

The following lexical grammar specifies the form of encoded URIs.

Syntax

uri :::
uriCharactersopt
uriCharacters :::
uriCharacter uriCharactersopt
uriCharacter :::
uriReserved
uriUnescaped
uriEscaped
uriReserved ::: one of
; / ? : @ & = + $ ,
uriUnescaped :::
uriAlpha
DecimalDigit
uriMark
uriEscaped :::
% HexDigit HexDigit
uriAlpha ::: one of
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
uriMark ::: one of
- _ . ! ~ * ' ( )

NOTE The above syntax is based upon RFC 2396 and does not reflect changes introduced by the more recent RFC 3986.

Runtime Semantics

When a code unit to be included in a URI is not listed above or is not intended to have the special meaning sometimes given to the reserved code units, that code unit must be encoded. The code unit is transformed into its UTF-8 encoding, with surrogate pairs first converted from UTF-16 to the corresponding code point value. (Note that for code units in the range [0,127] this results in a single octet with the same value.) The resulting sequence of octets is then transformed into a String with each octet represented by an escape sequence of the form "%xx".

18.2.6.1.1 Runtime Semantics: Encode ( string, unescapedSet )

The encoding and escaping process is described by the abstract operation Encode taking two String arguments string and unescapedSet.

  1. Let strLen be the number of code units in string.
  2. Let R be the empty String.
  3. Let k be 0.
  4. Repeat
    1. If k equals strLen, return R.
    2. Let C be the code unit at index k within string.
    3. If C is in unescapedSet, then
      1. Let S be a String containing only the code unit C.
      2. Let R be a new String value computed by concatenating the previous value of R and S.
    4. Else C is not in unescapedSet,
      1. If the code unit value of C is not less than 0xDC00 and not greater than 0xDFFF, throw a URIError exception.
      2. If the code unit value of C is less than 0xD800 or greater than 0xDBFF, then
        1. Let V be the code unit value of C.
      3. Else,
        1. Increase k by 1.
        2. If k equals strLen, throw a URIError exception.
        3. Let kChar be the code unit value of the code unit at index k within string.
        4. If kChar is less than 0xDC00 or greater than 0xDFFF, throw a URIError exception.
        5. Let V be UTF16Decode(C, kChar).
      4. Let Octets be the array of octets resulting by applying the UTF-8 transformation to V, and let L be the array size.
      5. Let j be 0.
      6. Repeat, while j < L
        1. Let jOctet be the value at index j within Octets.
        2. Let S be a String containing three code units "%XY" where XY are two uppercase hexadecimal digits encoding the value of jOctet.
        3. Let R be a new String value computed by concatenating the previous value of R and S.
        4. Increase j by 1.
    5. Increase k by 1.

18.2.6.1.2 Runtime Semantics: Decode ( string, reservedSet )

The unescaping and decoding process is described by the abstract operation Decode taking two String arguments string and reservedSet.

  1. Let strLen be the number of code units in string.
  2. Let R be the empty String.
  3. Let k be 0.
  4. Repeat
    1. If k equals strLen, return R.
    2. Let C be the code unit at index k within string.
    3. If C is not "%", then
      1. Let S be the String containing only the code unit C.
    4. Else C is "%",
      1. Let start be k.
      2. If k + 2 is greater than or equal to strLen, throw a URIError exception.
      3. If the code units at index (k+1) and (k + 2) within string do not represent hexadecimal digits, throw a URIError exception.
      4. Let B be the 8-bit value represented by the two hexadecimal digits at index (k + 1) and (k + 2).
      5. Increment k by 2.
      6. If the most significant bit in B is 0, then
        1. Let C be the code unit with code unit value B.
        2. If C is not in reservedSet, then
          1. Let S be the String containing only the code unit C.
        3. Else C is in reservedSet,
          1. Let S be the substring of string from index start to index k inclusive.
      7. Else the most significant bit in B is 1,
        1. Let n be the smallest nonnegative integer such that (B << n) & 0x80 is equal to 0.
        2. If n equals 1 or n is greater than 4, throw a URIError exception.
        3. Let Octets be an array of 8-bit integers of size n.
        4. Put B into Octets at index 0.
        5. If k + (3 × (n – 1)) is greater than or equal to strLen, throw a URIError exception.
        6. Let j be 1.
        7. Repeat, while j < n
          1. Increment k by 1.
          2. If the code unit at index k within string is not "%", throw a URIError exception.
          3. If the code units at index (k +1) and (k + 2) within string do not represent hexadecimal digits, throw a URIError exception.
          4. Let B be the 8-bit value represented by the two hexadecimal digits at index (k + 1) and (k + 2).
          5. If the two most significant bits in B are not 10, throw a URIError exception.
          6. Increment k by 2.
          7. Put B into Octets at index j.
          8. Increment j by 1.
        8. Let V be the value obtained by applying the UTF-8 transformation to Octets, that is, from an array of octets into a 21-bit value. If Octets does not contain a valid UTF-8 encoding of a Unicode code point throw a URIError exception.
        9. If V < 0x10000, then
          1. Let C be the code unit V.
          2. If C is not in reservedSet, then
            1. Let S be the String containing only the code unit C.
          3. Else C is in reservedSet,
            1. Let S be the substring of string from index start to index k inclusive.
        10. Else V ≥ 0x10000,
          1. Let L be (((V – 0x10000) & 0x3FF) + 0xDC00).
          2. Let H be ((((V – 0x10000) >> 10) & 0x3FF) + 0xD800).
          3. Let S be the String containing the two code units H and L.
    5. Let R be a new String value computed by concatenating the previous value of R and S.
    6. Increase k by 1.

NOTE This syntax of Uniform Resource Identifiers is based upon RFC 2396 and does not reflect the more recent RFC 3986 which replaces RFC 2396. A formal description and implementation of UTF-8 is given in RFC 3629.

In UTF-8, characters are encoded using sequences of 1 to 6 octets. The only octet of a sequence of one has the higher-order bit set to 0, the remaining 7 bits being used to encode the character value. In a sequence of n octets, n>1, the initial octet has the n higher-order bits set to 1, followed by a bit set to 0. The remaining bits of that octet contain bits from the value of the character to be encoded. The following octets all have the higher-order bit set to 1 and the following bit set to 0, leaving 6 bits in each to contain bits from the character to be encoded. The possible UTF-8 encodings of ECMAScript characters are specified in Table 43.

Table 43 (Informative) — UTF-8 Encodings
Code Unit Value Representation 1st Octet 2nd Octet 3rd Octet 4th Octet
0x0000 - 0x007F 00000000 0zzzzzzz 0zzzzzzz
0x0080 - 0x07FF 00000yyy yyzzzzzz 110yyyyy 10zzzzzz
0x0800 - 0xD7FF xxxxyyyy yyzzzzzz 1110xxxx 10yyyyyy 10zzzzzz
0xD800 - 0xDBFF
followed by
0xDC00 – 0xDFFF
110110vv vvwwwwxx
followed by
110111yy yyzzzzzz
11110uuu 10uuwwww 10xxyyyy 10zzzzzz
0xD800 - 0xDBFF
not followed by
0xDC00 – 0xDFFF
causes URIError
0xDC00 – 0xDFFF causes URIError
0xE000 - 0xFFFF xxxxyyyy yyzzzzzz 1110xxxx 10yyyyyy 10zzzzzz

Where
      uuuuu = vvvv + 1
to account for the addition of 0x10000 as in Surrogates, section 3.7, of the Unicode Standard.

The range of code unit values 0xD800-0xDFFF is used to encode surrogate pairs; the above transformation combines a UTF-16 surrogate pair into a UTF-32 representation and encodes the resulting 21-bit value in UTF-8. Decoding reconstructs the surrogate pair.

RFC 3629 prohibits the decoding of invalid UTF-8 octet sequences. For example, the invalid sequence C0 80 must not decode into the code unit 0x0000. Implementations of the Decode algorithm are required to throw a URIError when encountering such invalid sequences.

18.2.6.2 decodeURI (encodedURI)

The decodeURI function computes a new version of a URI in which each escape sequence and UTF-8 encoding of the sort that might be introduced by the encodeURI function is replaced with the UTF-16 encoding of the code points that it represents. Escape sequences that could not have been introduced by encodeURI are not replaced.

The decodeURI function is the %decodeURI% intrinsic object. When the decodeURI function is called with one argument encodedURI, the following steps are taken:

  1. Let uriString be ToString(encodedURI).
  2. ReturnIfAbrupt(uriString).
  3. Let reservedURISet be a String containing one instance of each code unit valid in uriReserved plus "#".
  4. Return Decode(uriString, reservedURISet).

NOTE The code point "#" is not decoded from escape sequences even though it is not a reserved URI code point.

18.2.6.3 decodeURIComponent (encodedURIComponent)

The decodeURIComponent function computes a new version of a URI in which each escape sequence and UTF-8 encoding of the sort that might be introduced by the encodeURIComponent function is replaced with the UTF-16 encoding of the code points that it represents.

The decodeURIComponent function is the %decodeURIComponent% intrinsic object. When the decodeURIComponent function is called with one argument encodedURIComponent, the following steps are taken:

  1. Let componentString be ToString(encodedURIComponent).
  2. ReturnIfAbrupt(componentString).
  3. Let reservedURIComponentSet be the empty String.
  4. Return Decode(componentString, reservedURIComponentSet).

18.2.6.4 encodeURI (uri)

The encodeURI function computes a new version of a UTF-16 encoded (6.1.4) URI in which each instance of certain code points is replaced by one, two, three, or four escape sequences representing the UTF-8 encoding of the code points.

The encodeURI function is the %encodeURI% intrinsic object. When the encodeURI function is called with one argument uri, the following steps are taken:

  1. Let uriString be ToString(uri).
  2. ReturnIfAbrupt(uriString).
  3. Let unescapedURISet be a String containing one instance of each code unit valid in uriReserved and uriUnescaped plus "#".
  4. Return Encode(uriString, unescapedURISet).

NOTE The code unit "#" is not encoded to an escape sequence even though it is not a reserved or unescaped URI code point.

18.2.6.5 encodeURIComponent (uriComponent)

The encodeURIComponent function computes a new version of a UTF-16 encoded (6.1.4) URI in which each instance of certain code points is replaced by one, two, three, or four escape sequences representing the UTF-8 encoding of the code point.

The encodeURIComponent function is the %encodeURIComponent% intrinsic object. When the encodeURIComponent function is called with one argument uriComponent, the following steps are taken:

  1. Let componentString be ToString(uriComponent).
  2. ReturnIfAbrupt(componentString).
  3. Let unescapedURIComponentSet be a String containing one instance of each code unit valid in uriUnescaped.
  4. Return Encode(componentString, unescapedURIComponentSet).

18.3 Constructor Properties of the Global Object

18.3.1 Array ( . . . )

See 22.1.1.

18.3.2 ArrayBuffer ( . . . )

See 24.1.2.

18.3.3 Boolean ( . . . )

See 19.3.1.

18.3.4 DataView ( . . . )

See 24.2.2.

18.3.5 Date ( . . . )

See 20.3.2.

18.3.6 Error ( . . . )

See 19.5.1.

18.3.7 EvalError ( . . . )

See 19.5.5.1.

18.3.8 Float32Array ( . . . )

See 22.2.4.

18.3.9 Float64Array ( . . . )

See 22.2.4.

18.3.10 Function ( . . . )

See 19.2.1.

18.3.11 Int8Array ( . . . )

See 22.2.4.

18.3.12 Int16Array ( . . . )

See 22.2.4.

18.3.13 Int32Array ( . . . )

See 22.2.4.

18.3.14 Map ( . . . )

See 23.1.1.

18.3.15 Number ( . . . )

See 20.1.1.

18.3.16 Object ( . . . )

See 19.1.1.

18.3.17 Proxy ( . . . )

See 26.2.1.

18.3.18 Promise ( . . . )

See 25.4.3.

18.3.19 RangeError ( . . . )

See 19.5.5.2.

18.3.20 ReferenceError ( . . . )

See 19.5.5.3.

18.3.21 RegExp ( . . . )

See 21.2.3.

18.3.22 Set ( . . . )

See 23.2.1.

18.3.23 String ( . . . )

See 21.1.1.

18.3.24 Symbol ( . . . )

See 19.4.1.

18.3.25 SyntaxError ( . . . )

See 19.5.5.4.

18.3.26 TypeError ( . . . )

See 19.5.5.5.

18.3.27 Uint8Array ( . . . )

See 22.2.4.

18.3.28 Uint8ClampedArray ( . . . )

See 22.2.4.

18.3.29 Uint16Array ( . . . )

See 22.2.4.

18.3.30 Uint32Array ( . . . )

See 22.2.4.

18.3.31 URIError ( . . . )

See 19.5.5.6.

18.3.32 WeakMap ( . . . )

See 23.3.1.

18.3.33 WeakSet ( . . . )

See 23.4.

18.4 Other Properties of the Global Object

18.4.1 JSON

See 24.3.

18.4.2 Math

See 20.2.

18.4.3 Reflect

See 26.1.