19 The Global Object

global object는:

19.1 Value Properties of the Global Object

19.1.1 globalThis

Realm Record realm 안의 global object"globalThis" property의 initial value는 realm.[[GlobalEnv]].[[GlobalThisValue]]입니다.

이 property는 attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

19.1.2 Infinity

global object"Infinity" property의 initial value는 +∞𝔽입니다(6.1.6.1 참조).

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

19.1.3 NaN

global object"NaN" property의 initial value는 NaN입니다(6.1.6.1 참조).

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

19.1.4 undefined

global object"undefined" property의 initial value는 undefined입니다(6.1.1 참조).

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

19.2 Function Properties of the Global Object

19.2.1 eval ( source )

이 function은 %eval% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. PerformEval(source, false, false)를 반환한다.

19.2.1.1 PerformEval ( source, strictCaller, direct )

The abstract operation PerformEval takes arguments source (an ECMAScript language value), strictCaller (a Boolean), and direct (a Boolean) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. Assert: directfalse이면, strictCallerfalse이다.
  2. source가 String이 아니면, source를 반환한다.
  3. evalRealm을 current Realm Record로 둔다.
  4. NOTE: direct eval의 경우, evalRealmeval의 caller와 eval function 자체 둘 다의 realm이다.
  5. HostEnsureCanCompileStrings(evalRealm, « », source, direct)를 수행한다.
  6. inFuncfalse로 둔다.
  7. inMethodfalse로 둔다.
  8. inDerivedCtorfalse로 둔다.
  9. inClassFieldInitializerfalse로 둔다.
  10. directtrue이면, 다음을 수행한다.
    1. thisEnvRecordGetThisEnvironment()로 둔다.
    2. thisEnvRecordFunction Environment Record이면, 다음을 수행한다.
      1. functhisEnvRecord.[[FunctionObject]]로 둔다.
      2. inFunctrue로 설정한다.
      3. inMethodthisEnvRecord.HasSuperBinding()으로 설정한다.
      4. func.[[ConstructorKind]]derived이면, inDerivedCtortrue로 설정한다.
      5. classFieldInitializerNamefunc.[[ClassFieldInitializerName]]로 둔다.
      6. classFieldInitializerNameempty가 아니면, inClassFieldInitializertrue로 설정한다.
  11. implementation-defined order로 다음 substep을 수행하며, parsing과 error detection을 interleave할 수 있다:
    1. scriptParseText(source, Script)로 둔다.
    2. script가 error의 List이면, SyntaxError exception을 throw한다.
    3. script Contains ScriptBodyfalse이면, undefined를 반환한다.
    4. bodyscriptScriptBody로 둔다.
    5. inFuncfalse이고 body Contains NewTarget이면, SyntaxError exception을 throw한다.
    6. inMethodfalse이고 body Contains SuperProperty이면, SyntaxError exception을 throw한다.
    7. inDerivedCtorfalse이고 body Contains SuperCall이면, SyntaxError exception을 throw한다.
    8. inClassFieldInitializertrue이고 bodyContainsArgumentstrue이면, SyntaxError exception을 throw한다.
  12. strictCallertrue이면, strictEvaltrue로 둔다.
  13. 그렇지 않으면, strictEvalscriptScriptIsStrict로 둔다.
  14. runningContextrunning execution context로 둔다.
  15. NOTE: directtrue이면, runningContextdirect eval을 수행한 execution context일 것이다. directfalse이면, runningContexteval function invocation에 대한 execution context일 것이다.
  16. directtrue이면, 다음을 수행한다.
    1. lexicalEnvNewDeclarativeEnvironment(runningContext의 LexicalEnvironment)로 둔다.
    2. variableEnvrunningContext의 VariableEnvironment로 둔다.
    3. privateEnvrunningContext의 PrivateEnvironment로 둔다.
  17. 그렇지 않으면,
    1. lexicalEnvNewDeclarativeEnvironment(evalRealm.[[GlobalEnv]])로 둔다.
    2. variableEnvevalRealm.[[GlobalEnv]]로 둔다.
    3. privateEnvnull로 둔다.
  18. strictEvaltrue이면, variableEnvlexicalEnv로 설정한다.
  19. runningContext가 already suspended가 아니면, runningContext를 suspend한다.
  20. evalContext를 새 ECMAScript code execution context로 둔다.
  21. evalContext의 Function을 null로 설정한다.
  22. evalContextRealmevalRealm으로 설정한다.
  23. evalContext의 ScriptOrModule을 runningContext의 ScriptOrModule로 설정한다.
  24. evalContext의 VariableEnvironment를 variableEnv로 설정한다.
  25. evalContext의 LexicalEnvironment를 lexicalEnv로 설정한다.
  26. evalContext의 PrivateEnvironment를 privateEnv로 설정한다.
  27. evalContextexecution context stack에 push한다; evalContext는 이제 running execution context이다.
  28. resultCompletion(EvalDeclarationInstantiation(body, variableEnv, lexicalEnv, privateEnv, strictEval))으로 둔다.
  29. resultnormal completion이면, 다음을 수행한다.
    1. resultCompletion(bodyEvaluation)으로 설정한다.
  30. resultnormal completion이고 result.[[Value]]empty이면, 다음을 수행한다.
    1. resultNormalCompletion(undefined)로 설정한다.
  31. evalContext를 suspend하고 execution context stack에서 remove한다.
  32. execution context stack의 top에 now 있는 context를 running execution context로 resume한다.
  33. result를 반환한다.
Note

eval code는 calling context의 code나 eval code 중 하나가 strict mode code인 경우 eval을 invoked한 calling context의 variable environment 안에 variable 또는 function binding을 instantiate할 수 없습니다. 대신 such binding은 eval code에만 accessible한 새 VariableEnvironment 안에 instantiated됩니다. let, const, 또는 class declaration에 의해 introduced된 binding은 항상 새 LexicalEnvironment 안에 instantiated됩니다.

19.2.1.2 HostEnsureCanCompileStrings ( calleeRealm, paramStrings, bodyString, direct )

The host-defined abstract operation HostEnsureCanCompileStrings takes arguments calleeRealm (a Realm Record), paramStrings (a List of Strings), bodyString (a String), and direct (a Boolean) and returns either a normal completion containing unused or a throw completion. 개발자가 string을 ECMAScript code로 interpret하고 evaluate할 수 있게 하는 certain ECMAScript function을 host environment가 block할 수 있게 합니다.

paramStrings는 function constructor 중 하나를 사용할 때 parameters list를 build하기 위해 together concatenated될 string들을 represent합니다. bodyString은 function body 또는 eval call에 passed된 string을 represent합니다. direct는 evaluation이 direct eval인지 여부를 signifies합니다.

HostEnsureCanCompileStrings의 default implementation은 NormalCompletion(unused)를 반환하는 것입니다.

19.2.1.3 EvalDeclarationInstantiation ( body, variableEnv, lexicalEnv, privateEnv, strict )

The abstract operation EvalDeclarationInstantiation takes arguments body (a ScriptBody Parse Node), variableEnv (an Environment Record), lexicalEnv (a Declarative Environment Record), privateEnv (a PrivateEnvironment Record or null), and strict (a Boolean) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. variableNamesbodyVarDeclaredNames라고 하자.
  2. variableDeclsbodyVarScopedDeclarations라고 하자.
  3. strictfalse이면,
    1. variableEnvGlobal Environment Record이면,
      1. variableNames의 각 요소 name에 대해 다음을 수행한다.
        1. HasLexicalDeclaration(variableEnv, name)이 true이면, SyntaxError 예외를 던진다.
        2. NOTE: eval은 전역 lexical 선언에 의해 가려질 전역 var 선언을 생성하지 않는다.
    2. thisEnvlexicalEnv라고 하자.
    3. Assert: 다음 루프는 종료된다.
    4. thisEnvvariableEnv가 같은 Environment Record가 아닌 동안 반복한다.
      1. thisEnvObject Environment Record가 아니면,
        1. NOTE: with 문장의 환경은 어떤 lexical 선언도 포함할 수 없으므로 var/let 호이스팅 충돌을 검사할 필요가 없다.
        2. variableNames의 각 요소 name에 대해 다음을 수행한다.
          1. thisEnv.HasBinding(name)이 true이면,
            1. host가 웹 브라우저이거나 그 밖에 Catch Blocks 안의 VariableStatements를 지원하면,
              1. thisEnvCatch 절에 대한 Environment Record가 아니면, SyntaxError 예외를 던진다.
            2. 그렇지 않으면,
              1. SyntaxError 예외를 던진다.
          2. NOTE: direct eval은 var 선언을 같은 이름의 lexical 선언 위로 호이스팅하지 않는다.
      2. thisEnvthisEnv.[[OuterEnv]]로 설정한다.
  4. privateIdentifiers를 새로운 빈 List라고 하자.
  5. pointerprivateEnv라고 하자.
  6. pointernull이 아닌 동안 반복한다.
    1. pointer.[[Names]]의 각 Private Name binding에 대해 다음을 수행한다.
      1. privateIdentifiersbinding.[[Description]]을 포함하지 않으면, binding.[[Description]]privateIdentifiers에 추가한다.
    2. pointerpointer.[[OuterPrivateEnvironment]]로 설정한다.
  7. bodyAllPrivateIdentifiersValid에 인수 privateIdentifiers를 전달한 결과가 false이면, SyntaxError 예외를 던진다.
  8. funcsToInitialize를 새로운 빈 List라고 하자.
  9. declaredFuncNames를 새로운 빈 List라고 하자.
  10. variableDecls의 각 요소 variableDecl에 대해, List의 역순으로 다음을 수행한다.
    1. variableDeclVariableDeclaration, ForBinding 또는 BindingIdentifier 중 어느 것도 아니면,
      1. Assert: variableDeclFunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이다.
      2. NOTE: 같은 이름에 대해 여러 함수 선언이 있으면, 마지막 선언이 사용된다.
      3. funcNamevariableDeclBoundNames의 유일한 요소라고 하자.
      4. declaredFuncNamesfuncName을 포함하지 않으면,
        1. variableEnvGlobal Environment Record이면,
          1. funcDefinable을 ? CanDeclareGlobalFunction(variableEnv, funcName)이라고 하자.
          2. funcDefinablefalse이면, TypeError 예외를 던진다.
        2. funcNamedeclaredFuncNames에 추가한다.
        3. variableDeclfuncsToInitialize의 첫 번째 요소로 삽입한다.
  11. declaredVariableNames를 새로운 빈 List라고 하자.
  12. variableDecls의 각 요소 variableDecl에 대해 다음을 수행한다.
    1. variableDeclVariableDeclaration, ForBinding 또는 BindingIdentifier 중 하나이면,
      1. variableDeclBoundNames의 각 String name에 대해 다음을 수행한다.
        1. declaredFuncNamesname을 포함하지 않으면,
          1. variableEnvGlobal Environment Record이면,
            1. variableDefinable을 ? CanDeclareGlobalVar(variableEnv, name)라고 하자.
            2. variableDefinablefalse이면, TypeError 예외를 던진다.
          2. declaredVariableNamesname을 포함하지 않으면,
            1. namedeclaredVariableNames에 추가한다.
  13. strictfalse이고 host가 웹 브라우저이거나 그 밖에 Block-Level Function Declarations Web Legacy Compatibility Semantics를 지원하면,
    1. declaredFuncOrVariableNamesdeclaredFuncNamesdeclaredVariableNameslist-concatenation이라고 하자.
    2. body Contains xtrueBlock, CaseClause 또는 DefaultClause xStatementList에 직접 포함된 각 FunctionDeclaration funcDecl에 대해 다음을 수행한다.
      1. funcNamefuncDeclBindingIdentifierStringValue라고 하자.
      2. FunctionDeclaration funcDeclfuncNameBindingIdentifier로 갖는 VariableStatement로 대체해도 body에 대한 Early Errors가 생성되지 않으면,
        1. bindingExistsfalse라고 하자.
        2. thisEnvlexicalEnv로 설정한다.
        3. Assert: 다음 루프는 종료된다.
        4. thisEnvvariableEnv가 아닌 동안 반복한다.
          1. thisEnvObject Environment Record가 아니면,
            1. thisEnv.HasBinding(funcName)이 true이면,
              1. host가 웹 브라우저이거나 그 밖에 Catch Blocks 안의 VariableStatements를 지원하면,
                1. thisEnvCatch 절에 대한 Environment Record가 아니면, bindingExiststrue로 설정한다.
              2. 그렇지 않으면,
                1. bindingExiststrue로 설정한다.
          2. thisEnvthisEnv.[[OuterEnv]]로 설정한다.
        5. bindingExistsfalse이고 variableEnvGlobal Environment Record이면,
          1. HasLexicalDeclaration(variableEnv, funcName)이 false이면,
            1. funcDefinable을 ? CanDeclareGlobalVar(variableEnv, funcName)라고 하자.
          2. 그렇지 않으면,
            1. funcDefinablefalse라고 하자.
        6. 그렇지 않으면,
          1. funcDefinabletrue라고 하자.
        7. bindingExistsfalse이고 funcDefinabletrue이면,
          1. declaredFuncOrVariableNamesfuncName을 포함하지 않으면,
            1. variableEnvGlobal Environment Record이면,
              1. CreateGlobalVarBinding(variableEnv, funcName, true)를 수행한다.
            2. 그렇지 않으면,
              1. bindingExists를 ! variableEnv.HasBinding(funcName)으로 설정한다.
              2. bindingExistsfalse이면,
                1. variableEnv.CreateMutableBinding(funcName, true)를 수행한다.
                2. variableEnv.InitializeBinding(funcName, undefined)를 수행한다.
            3. funcNamedeclaredFuncOrVariableNames에 추가한다.
          2. FunctionDeclaration funcDecl이 평가될 때, 15.2.6에 제공된 FunctionDeclaration Evaluation 알고리즘 대신 다음 단계를 수행한다.
            1. globalEnv를 실행 중인 실행 컨텍스트의 VariableEnvironment라고 하자.
            2. blockEnv를 실행 중인 실행 컨텍스트의 LexicalEnvironment라고 하자.
            3. funcObj를 ! blockEnv.GetBindingValue(funcName, false)라고 하자.
            4. globalEnv.SetMutableBinding(funcName, funcObj, false)를 수행한다.
            5. unused를 반환한다.
  14. NOTE: variableEnvGlobal Environment Record이고 전역 객체가 Proxy exotic object인 경우가 아니면, 이 알고리즘 단계 이후에는 abnormal termination이 발생하지 않는다.
  15. lexicalDeclsbodyLexicallyScopedDeclarations라고 하자.
  16. lexicalDecls의 각 요소 lexicalDecl에 대해 다음을 수행한다.
    1. NOTE: Lexically declared name은 여기서 인스턴스화만 되고 초기화되지는 않는다.
    2. lexicalDeclBoundNames의 각 요소 name에 대해 다음을 수행한다.
      1. lexicalDeclIsConstantDeclarationtrue이면,
        1. lexicalEnv.CreateImmutableBinding(name, true)를 수행한다.
      2. 그렇지 않으면,
        1. lexicalEnv.CreateMutableBinding(name, false)를 수행한다.
  17. funcsToInitialize의 각 Parse Node funcDecl에 대해 다음을 수행한다.
    1. funcNamefuncDeclBoundNames의 유일한 요소라고 하자.
    2. funcObjfuncDeclInstantiateFunctionObject에 인수 lexicalEnvprivateEnv를 전달한 결과라고 하자.
    3. variableEnvGlobal Environment Record이면,
      1. CreateGlobalFunctionBinding(variableEnv, funcName, funcObj, true)를 수행한다.
    4. 그렇지 않으면,
      1. bindingExists를 ! variableEnv.HasBinding(funcName)이라고 하자.
      2. bindingExistsfalse이면,
        1. NOTE: 다음 호출은 14 단계 이전의 검증 때문에 abrupt completion을 반환할 수 없다.
        2. variableEnv.CreateMutableBinding(funcName, true)를 수행한다.
        3. variableEnv.InitializeBinding(funcName, funcObj)를 수행한다.
      3. 그렇지 않으면,
        1. variableEnv.SetMutableBinding(funcName, funcObj, false)를 수행한다.
  18. declaredVariableNames의 각 String variableName에 대해 다음을 수행한다.
    1. variableEnvGlobal Environment Record이면,
      1. CreateGlobalVarBinding(variableEnv, variableName, true)를 수행한다.
    2. 그렇지 않으면,
      1. bindingExists를 ! variableEnv.HasBinding(variableName)이라고 하자.
      2. bindingExistsfalse이면,
        1. NOTE: 다음 호출은 14 단계 이전의 검증 때문에 abrupt completion을 반환할 수 없다.
        2. variableEnv.CreateMutableBinding(variableName, true)를 수행한다.
        3. variableEnv.InitializeBinding(variableName, undefined)를 수행한다.
  19. unused를 반환한다.

19.2.2 isFinite ( value )

이 function은 %isFinite% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. number를 ? ToNumber(value)로 둔다.
  2. numberfinite이면, true를 반환한다.
  3. false를 반환한다.

19.2.3 isNaN ( value )

이 function은 %isNaN% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. number를 ? ToNumber(value)로 둔다.
  2. numberNaN이면, true를 반환한다.
  3. false를 반환한다.
Note

ECMAScript code가 value XNaN인지 test하는 reliable way는 form X !== X의 expression입니다. result는 XNaN인 경우에만, 그리고 그 경우에만 true입니다.

19.2.4 parseFloat ( string )

이 function은 string argument의 contents를 decimal literal로 interpretation하여 dictated되는 Number value를 produce합니다.

이는 %parseFloat% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. inputString을 ? ToString(string)으로 둔다.
  2. trimmedString을 ! TrimString(inputString, start)로 둔다.
  3. trimmedStringToCodePoints(trimmedString)로 둔다.
  4. trimmedPrefixStrDecimalLiteral의 syntax를 satisfy하는 trimmed의 longest prefix로 둔다. 이는 trimmed 자체일 수도 있다. such prefix가 없으면, NaN을 반환한다.
  5. parsedNumberParseText(trimmedPrefix, StrDecimalLiteral)로 둔다.
  6. Assert: parsedNumberParse Node이다.
  7. parsedNumberStringNumericValue를 반환한다.
Note

이 function은 string의 leading portion만 Number value로 interpret할 수 있습니다; decimal literal의 notation의 part로 interpret될 수 없는 any code unit은 ignored되며, such code unit이 ignored되었다는 indication은 given되지 않습니다.

19.2.5 parseInt ( string, radix )

이 function은 specified된 radix에 따라 string의 contents를 interpretation하여 dictated되는 integral Number를 produce합니다. string 안의 leading white space는 ignored됩니다. radix가 0으로 coerces되면(undefined인 경우 등), number representation이 "0x" 또는 "0X"로 begins하는 경우를 제외하고 10으로 assumed되며, 그런 경우에는 16으로 assumed됩니다. radix가 16이면, number representation은 optionally "0x" 또는 "0X"로 begin할 수 있습니다.

이는 %parseInt% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. inputString을 ? ToString(string)으로 둔다.
  2. trimmedString을 ! TrimString(inputString, start)로 둔다.
  3. sign을 1로 둔다.
  4. trimmedString이 empty가 아니고 trimmedString의 first code unit이 code unit 0x002D (HYPHEN-MINUS)이면, sign을 -1로 설정한다.
  5. trimmedString이 empty가 아니고 trimmedString의 first code unit이 code unit 0x002B (PLUS SIGN) 또는 code unit 0x002D (HYPHEN-MINUS) 중 하나이면, trimmedString을 index 1부터의 trimmedStringsubstring으로 설정한다.
  6. radixMV(? ToInt32(radix))로 둔다.
  7. stripPrefixtrue로 둔다.
  8. radixMV ≠ 0이면, 다음을 수행한다.
    1. radixMV < 2 또는 radixMV > 36이면, NaN을 반환한다.
    2. radixMV ≠ 16이면, stripPrefixfalse로 설정한다.
  9. 그렇지 않으면,
    1. radixMV를 10으로 설정한다.
  10. stripPrefixtrue이면, 다음을 수행한다.
    1. trimmedString의 length가 ≥ 2이고 trimmedString의 first two code unit이 "0x" 또는 "0X" 중 하나이면, 다음을 수행한다.
      1. trimmedString을 index 2부터의 trimmedStringsubstring으로 설정한다.
      2. radixMV를 16으로 설정한다.
  11. trimmedString이 radix-radixMV digit이 아닌 code unit을 contain하면, endtrimmedString 안에서 first such code unit의 index로 둔다; 그렇지 않으면 endtrimmedString의 length로 둔다.
  12. numberString을 0부터 end까지의 trimmedStringsubstring으로 둔다.
  13. numberString이 empty이면, NaN을 반환한다.
  14. mathInt를 radix-radixMV notation으로 numberString에 의해 represented되는 integer value로 둔다. 여기서 A부터 Z까지와 a부터 z까지의 letters는 values 10 through 35를 가진 digits로 사용된다. (그러나 radixMV = 10이고 numberString이 20개보다 많은 significant digits를 contain하면, 20번째 이후의 every significant digit은 implementation의 option에 따라 0 digit으로 replaced될 수 있다; 그리고 radixMV가 2, 4, 8, 10, 16, 또는 32 중 하나가 아니면, mathInt는 radix-radixMV notation에서 numberString이 denoted하는 integer value를 representing하는 implementation-approximated integer일 수 있다.)
  15. mathInt = 0이면, 다음을 수행한다.
    1. sign = -1이면, -0𝔽를 반환한다.
    2. +0𝔽를 반환한다.
  16. 𝔽(sign × mathInt)를 반환한다.
Note

이 function은 string의 leading portion만 integer value로 interpret할 수 있습니다; integer의 notation의 part로 interpret될 수 없는 any code unit은 ignored되며, such code unit이 ignored되었다는 indication은 given되지 않습니다.

19.2.6 URI Handling Functions

Uniform Resource Identifier, 즉 URI는 Internet에서 resource(예: web page 또는 file)와 그것에 access하기 위한 transport protocol(예: HTTP 또는 FTP)을 identify하는 String입니다. ECMAScript language 자체는 이 section에 described된 것처럼 URI를 encode 및 decode하는 function을 제외하고 URI 사용을 위한 어떤 support도 provide하지 않습니다. encodeURIdecodeURI는 complete URI와 함께 work하도록 intended됩니다; 이들은 any reserved character가 special meaning(예: delimiter)을 가지도록 intended된다고 assume하므로 encoded되지 않습니다. encodeURIComponentdecodeURIComponent는 URI의 individual component와 함께 work하도록 intended됩니다; 이들은 any reserved character가 text를 represent하며 component가 complete URI의 part일 때 special meaning을 avoid하기 위해 encoded되어야 한다고 assume합니다.

Note 1

reserved character의 set은 RFC 2396에 based하며, 더 recent한 RFC 3986에 의해 introduced된 change를 reflect하지 않습니다.

Note 2

ECMAScript의 많은 implementation은 web page를 manipulate하는 additional function 및 method를 provide합니다; 이러한 function은 이 standard의 scope 밖입니다.

19.2.6.1 decodeURI ( encodedURI )

이 function은 encodeURI function에 의해 introduced될 수 있는 sort의 각 escape sequence와 UTF-8 encoding이 그것이 represent하는 code point의 UTF-16 encoding으로 replaced된 URI의 new version을 computes합니다. encodeURI에 의해 introduced될 수 없었던 escape sequence는 replaced되지 않습니다.

이는 %decodeURI% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. uriString을 ? ToString(encodedURI)로 둔다.
  2. preserveEscapeSet";/?:@&=+$,#"로 둔다.
  3. Decode(uriString, preserveEscapeSet)를 반환한다.

19.2.6.2 decodeURIComponent ( encodedURIComponent )

이 function은 encodeURIComponent function에 의해 introduced될 수 있는 sort의 각 escape sequence와 UTF-8 encoding이 그것이 represent하는 code point의 UTF-16 encoding으로 replaced된 URI의 new version을 computes합니다.

이는 %decodeURIComponent% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. componentString을 ? ToString(encodedURIComponent)으로 둔다.
  2. preserveEscapeSet을 empty String으로 둔다.
  3. Decode(componentString, preserveEscapeSet)를 반환한다.

19.2.6.3 encodeURI ( uri )

이 function은 certain code point의 각 instance가 code point의 UTF-8 encoding을 represent하는 one, two, three, or four escape sequence로 replaced된 UTF-16 encoded(6.1.4) URI의 new version을 computes합니다.

이는 %encodeURI% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. uriString을 ? ToString(uri)로 둔다.
  2. extraUnescaped";/?:@&=+$,#"로 둔다.
  3. Encode(uriString, extraUnescaped)를 반환한다.

19.2.6.4 encodeURIComponent ( uriComponent )

이 function은 certain code point의 각 instance가 code point의 UTF-8 encoding을 represent하는 one, two, three, or four escape sequence로 replaced된 UTF-16 encoded(6.1.4) URI의 new version을 computes합니다.

이는 %encodeURIComponent% intrinsic object입니다.

called될 때 다음 step을 수행합니다:

  1. componentString을 ? ToString(uriComponent)로 둔다.
  2. extraUnescaped를 empty String으로 둔다.
  3. Encode(componentString, extraUnescaped)를 반환한다.

19.2.6.5 Encode ( string, extraUnescaped )

The abstract operation Encode takes arguments string (a String) and extraUnescaped (a String) and returns either a normal completion containing a String or a throw completion. 6.1.4에 described된 것처럼 string을 UTF-16 encoded code point의 sequence로 interpreting하여 URI encoding과 escaping을 수행합니다. character가 RFC 2396에서 unreserved로 identified되거나 extraUnescaped 안에 appear하면, escaped되지 않습니다. It performs the following steps when called:

  1. lengthstring의 length로 둔다.
  2. result를 empty String으로 둔다.
  3. alwaysUnescaped를 ASCII word character와 "-.!~*'()"string-concatenation으로 둔다.
  4. unescapedSetalwaysUnescapedextraUnescapedstring-concatenation으로 둔다.
  5. k를 0으로 둔다.
  6. Repeat, k < length인 동안,
    1. codeUnitstring 안의 index k에 있는 code unit으로 둔다.
    2. unescapedSetcodeUnit을 contain하면, 다음을 수행한다.
      1. kk + 1로 설정한다.
      2. resultresultcodeUnitstring-concatenation으로 설정한다.
    3. 그렇지 않으면,
      1. codePointCodePointAt(string, k)로 둔다.
      2. codePoint.[[IsUnpairedSurrogate]]true이면, URIError exception을 throw한다.
      3. kk + codePoint.[[CodeUnitCount]]로 설정한다.
      4. octetscodePoint.[[CodePoint]]에 UTF-8 transformation을 applying하여 resulting되는 octet의 List로 둔다.
      5. octets의 각 element octet에 대해, 다음을 수행한다.
        1. hex를 uppercase hexadecimal number로 formatted된 octet의 String representation으로 둔다.
        2. resultresult, "%", 및 StringPad(hex, 2, "0", start)의 string-concatenation으로 설정한다.
  7. result를 반환한다.
Note

percent-encoding은 individual octet을 represent하는 데 사용되므로, single code point는 multiple consecutive escape sequence(그 8-bit UTF-8 code unit 각각에 대해 하나)로 expressed될 수 있습니다.

19.2.6.6 Decode ( string, preserveEscapeSet )

The abstract operation Decode takes arguments string (a String) and preserveEscapeSet (a String) and returns either a normal completion containing a String or a throw completion. preserveEscapeSet 안의 Basic Latin character에 corresponding하는 any escape sequence를 preserving하면서 URI unescaping 및 decoding을 수행합니다. It performs the following steps when called:

  1. lengthstring의 length로 둔다.
  2. result를 empty String으로 둔다.
  3. k를 0으로 둔다.
  4. Repeat, k < length인 동안,
    1. codeUnitstring 안의 index k에 있는 code unit으로 둔다.
    2. segmentcodeUnit으로 둔다.
    3. codeUnit이 code unit 0x0025 (PERCENT SIGN)이면, 다음을 수행한다.
      1. k + 3 > length이면, URIError exception을 throw한다.
      2. escapestringk부터 k + 3까지의 substring으로 둔다.
      3. firstOctetParseHexOctet(string, k + 1)로 둔다.
      4. firstOctetinteger가 아니면, URIError exception을 throw한다.
      5. kk + 2로 설정한다.
      6. nfirstOctet 안의 leading 1 bit의 number로 둔다.
      7. n = 0이면, 다음을 수행한다.
        1. asciiChar를 numeric value가 firstOctet인 code unit으로 둔다.
        2. preserveEscapeSetasciiChar를 contain하면, segmentescape로 설정한다; 그렇지 않으면 segmentasciiChar로 설정한다.
      8. 그렇지 않으면,
        1. n = 1 또는 n > 4이면, URIError exception을 throw한다.
        2. octets를 « firstOctet »로 둔다.
        3. j를 1로 둔다.
        4. Repeat, j < n인 동안,
          1. kk + 1로 설정한다.
          2. k + 3 > length이면, URIError exception을 throw한다.
          3. string 안의 index k에 있는 code unit이 code unit 0x0025 (PERCENT SIGN)가 아니면, URIError exception을 throw한다.
          4. continuationByteParseHexOctet(string, k + 1)로 둔다.
          5. continuationByteinteger가 아니면, URIError exception을 throw한다.
          6. continuationByteoctets에 append한다.
          7. kk + 2로 설정한다.
          8. jj + 1로 설정한다.
        5. Assert: octets의 length는 n이다.
        6. octets가 Unicode code point의 valid UTF-8 encoding을 contain하지 않으면, URIError exception을 throw한다.
        7. codePointoctets에 UTF-8 transformation을 applying하여 얻은 code point로 둔다, 즉 octet의 List에서 21-bit value로 변환한 것이다.
        8. segmentUTF16EncodeCodePoint(codePoint)로 설정한다.
    4. resultresultsegmentstring-concatenation으로 설정한다.
    5. kk + 1로 설정한다.
  5. result를 반환한다.
Note

RFC 3629는 invalid UTF-8 octet sequence의 decoding을 prohibit합니다. 예를 들어 invalid sequence 0xC0 0x80은 code unit 0x0000으로 decode되어서는 안 됩니다. Decode algorithm의 implementation은 such invalid sequence를 encounter할 때 URIError를 throw해야 합니다.

19.2.6.7 ParseHexOctet ( string, position )

The abstract operation ParseHexOctet takes arguments string (a String) and position (a non-negative integer) and returns either a non-negative integer or a non-empty List of SyntaxError objects. string 안의 specified position에서 두 hexadecimal character의 sequence를 unsigned 8-bit integer로 parse합니다. It performs the following steps when called:

  1. lengthstring의 length로 둔다.
  2. Assert: position + 2 ≤ length이다.
  3. hexDigitsstringposition부터 position + 2까지의 substring으로 둔다.
  4. parseResultParseText(hexDigits, HexDigits[~Sep])로 둔다.
  5. parseResultParse Node가 아니면, parseResult를 반환한다.
  6. nparseResult의 MV로 둔다.
  7. Assert: n은 0부터 255까지의 inclusive interval 안에 있다.
  8. n을 반환한다.

19.3 Constructor Properties of the Global Object

19.3.1 AggregateError ( . . . )

20.5.7.1를 참조하십시오.

19.3.2 Array ( . . . )

23.1.1를 참조하십시오.

19.3.3 ArrayBuffer ( . . . )

25.1.4를 참조하십시오.

19.3.4 AsyncDisposableStack ( . . . )

27.4.1를 참조하십시오.

19.3.5 BigInt ( . . . )

21.2.1를 참조하십시오.

19.3.6 BigInt64Array ( . . . )

23.2.5를 참조하십시오.

19.3.7 BigUint64Array ( . . . )

23.2.5를 참조하십시오.

19.3.8 Boolean ( . . . )

20.3.1를 참조하십시오.

19.3.9 DataView ( . . . )

25.3.2를 참조하십시오.

19.3.10 Date ( . . . )

21.4.2를 참조하십시오.

19.3.11 DisposableStack ( . . . )

27.3.1를 참조하십시오.

19.3.12 Error ( . . . )

20.5.1를 참조하십시오.

19.3.13 EvalError ( . . . )

20.5.5.1를 참조하십시오.

19.3.14 FinalizationRegistry ( . . . )

26.2.1를 참조하십시오.

19.3.15 Float16Array ( . . . )

23.2.5를 참조하십시오.

19.3.16 Float32Array ( . . . )

23.2.5를 참조하십시오.

19.3.17 Float64Array ( . . . )

23.2.5를 참조하십시오.

19.3.18 Function ( . . . )

20.2.1를 참조하십시오.

19.3.19 Int8Array ( . . . )

23.2.5를 참조하십시오.

19.3.20 Int16Array ( . . . )

23.2.5를 참조하십시오.

19.3.21 Int32Array ( . . . )

23.2.5를 참조하십시오.

19.3.22 Iterator ( . . . )

27.1.3.1를 참조하십시오.

19.3.23 Map ( . . . )

24.1.1를 참조하십시오.

19.3.24 Number ( . . . )

21.1.1를 참조하십시오.

19.3.25 Object ( . . . )

20.1.1를 참조하십시오.

19.3.26 Promise ( . . . )

27.5.3를 참조하십시오.

19.3.27 Proxy ( . . . )

28.2.1를 참조하십시오.

19.3.28 RangeError ( . . . )

20.5.5.2를 참조하십시오.

19.3.29 ReferenceError ( . . . )

20.5.5.3를 참조하십시오.

19.3.30 RegExp ( . . . )

22.2.4를 참조하십시오.

19.3.31 Set ( . . . )

24.2.2를 참조하십시오.

19.3.32 SharedArrayBuffer ( . . . )

25.2.3를 참조하십시오.

19.3.33 String ( . . . )

22.1.1를 참조하십시오.

19.3.34 SuppressedError ( . . . )

20.5.8.1를 참조하십시오.

19.3.35 Symbol ( . . . )

20.4.1를 참조하십시오.

19.3.36 SyntaxError ( . . . )

20.5.5.4를 참조하십시오.

19.3.37 TypeError ( . . . )

20.5.5.5를 참조하십시오.

19.3.38 Uint8Array ( . . . )

23.2.5를 참조하십시오.

19.3.39 Uint8ClampedArray ( . . . )

23.2.5를 참조하십시오.

19.3.40 Uint16Array ( . . . )

23.2.5를 참조하십시오.

19.3.41 Uint32Array ( . . . )

23.2.5를 참조하십시오.

19.3.42 URIError ( . . . )

20.5.5.6를 참조하십시오.

19.3.43 WeakMap ( . . . )

24.3.1를 참조하십시오.

19.3.44 WeakRef ( . . . )

26.1.1를 참조하십시오.

19.3.45 WeakSet ( . . . )

24.4를 참조하십시오.

19.4 Other Properties of the Global Object

19.4.1 Atomics

25.4를 참조하십시오.

19.4.2 JSON

25.5를 참조하십시오.

19.4.3 Math

21.3를 참조하십시오.

19.4.4 Reflect

28.1를 참조하십시오.