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はNaN6.1.6.1を参照)です。

このpropertyはattributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持ちます。

19.1.4 undefined

global object"undefined" propertyのinitial valueはundefined6.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です。

これは呼び出されたとき、次のstepsを実行します:

  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. evalRealmcurrent 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. 次のsubstepsをimplementation-defined orderで実行し、parsingとerror detectionをinterleaveしてもよい:
    1. scriptParseText(source, Script)とする。
    2. scriptがerrorsのListなら、SyntaxError例外をthrowする。
    3. script Contains ScriptBodyfalseなら、undefinedを返す。
    4. bodyscriptScriptBodyとする。
    5. inFuncfalseであり、body Contains NewTargetであるなら、SyntaxError例外をthrowする。
    6. inMethodfalseであり、body Contains SuperPropertyであるなら、SyntaxError例外をthrowする。
    7. inDerivedCtorfalseであり、body Contains SuperCallであるなら、SyntaxError例外をthrowする。
    8. inClassFieldInitializertrueであり、bodyContainsArgumentstrueであるなら、SyntaxError例外を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がまだ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にあるcontextをrunning execution contextとしてresumeする。
  33. resultを返す。
Note

calling contextのcodeまたはeval codeのいずれかがstrict mode codeである場合、eval codeは、evalをinvokeしたcalling contextのvariable environment内にvariableまたはfunction bindingsをinstantiateできません。代わりに、そのようなbindingsはeval codeからのみaccessibleな新しいVariableEnvironment内にinstantiatedされます。letconst、またはclass declarationsによってintroducedされるbindingsは、常に新しい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. developersがstringsをECMAScript codeとしてinterpretおよびevaluateできるようにする特定のECMAScript functionsを、host environmentsがblockできるようにします。

paramStringsは、function constructorsのいずれかを使用するとき、parameters listをbuildするためにconcatenateされるstringsを表します。bodyStringは、function bodyまたはeval callに渡されるstringを表します。 directは、evaluationがdirect evalであるかどうかを示します。

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. bodyVarDeclaredNamesvariableNamesとする。
  2. bodyVarScopedDeclarationsvariableDeclsとする。
  3. strictfalseである場合、
    1. variableEnvGlobal Environment Recordである場合、
      1. variableNamesの各要素nameについて、次を行う。
        1. HasLexicalDeclaration(variableEnv, name)がtrueである場合、SyntaxError例外を投げる。
        2. NOTE: evalは、グローバルlexical宣言によってシャドーイングされることになるグローバルvar宣言を作成しない。
    2. lexicalEnvthisEnvとする。
    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. ホストがWebブラウザである、またはその他の形でCatch Blocks内のVariableStatementsをサポートする場合、
              1. thisEnvCatch節のEnvironment Recordでない場合、SyntaxError例外を投げる。
            2. そうでなければ、
              1. SyntaxError例外を投げる。
          2. NOTE: direct evalは、同名のlexical宣言を越えてvar宣言を巻き上げない。
      2. thisEnvthisEnv.[[OuterEnv]]に設定する。
  4. privateIdentifiersを新しい空のListとする。
  5. privateEnvpointerとする。
  6. pointernullでない間、繰り返す。
    1. pointer.[[Names]]の各Private Name bindingについて、次を行う。
      1. privateIdentifiersbinding.[[Description]]を含まない場合、binding.[[Description]]privateIdentifiersに追加する。
    2. pointerpointer.[[OuterPrivateEnvironment]]に設定する。
  7. privateIdentifiersを引数とするbodyAllPrivateIdentifiersValidfalseである場合、SyntaxError例外を投げる。
  8. funcsToInitializeを新しい空のListとする。
  9. declaredFuncNamesを新しい空のListとする。
  10. variableDeclsの各要素variableDeclについて、Listの逆順で、次を行う。
    1. variableDeclVariableDeclarationForBinding、またはBindingIdentifierのいずれでもない場合、
      1. Assert: variableDeclは、FunctionDeclarationGeneratorDeclarationAsyncFunctionDeclaration、またはAsyncGeneratorDeclarationのいずれかである。
      2. NOTE: 同じ名前に対して複数の関数宣言がある場合、最後の宣言が使用される。
      3. variableDeclBoundNamesの唯一の要素をfuncNameとする。
      4. declaredFuncNamesfuncNameを含まない場合、
        1. variableEnvGlobal Environment Recordである場合、
          1. CanDeclareGlobalFunction(variableEnv, funcName)をfuncDefinableとする。
          2. funcDefinablefalseである場合、TypeError例外を投げる。
        2. funcNamedeclaredFuncNamesに追加する。
        3. variableDeclfuncsToInitializeの最初の要素として挿入する。
  11. declaredVariableNamesを新しい空のListとする。
  12. variableDeclsの各要素variableDeclについて、次を行う。
    1. variableDeclVariableDeclarationForBinding、またはBindingIdentifierのいずれかである場合、
      1. variableDeclBoundNamesの各String nameについて、次を行う。
        1. declaredFuncNamesnameを含まない場合、
          1. variableEnvGlobal Environment Recordである場合、
            1. CanDeclareGlobalVar(variableEnv, name)をvariableDefinableとする。
            2. variableDefinablefalseである場合、TypeError例外を投げる。
          2. declaredVariableNamesnameを含まない場合、
            1. namedeclaredVariableNamesに追加する。
  13. strictfalseであり、かつホストがWebブラウザである、またはその他の形でBlock-Level Function Declarations Web Legacy Compatibility Semanticsをサポートする場合、
    1. declaredFuncNamesdeclaredVariableNameslist-concatenationdeclaredFuncOrVariableNamesとする。
    2. body Contains xtrueであるような任意のBlockCaseClause、またはDefaultClause xStatementListに直接含まれる各FunctionDeclaration funcDeclについて、次を行う。
      1. funcDeclBindingIdentifierStringValuefuncNameとする。
      2. FunctionDeclaration funcDeclを、funcNameBindingIdentifierとして持つVariableStatementに置き換えても、bodyに対してEarly Errorsが発生しない場合、
        1. bindingExistsfalseとする。
        2. thisEnvlexicalEnvに設定する。
        3. Assert: 次のループは終了する。
        4. thisEnvvariableEnvでない間、繰り返す。
          1. thisEnvObject Environment Recordでない場合、
            1. thisEnv.HasBinding(funcName)がtrueである場合、
              1. ホストがWebブラウザである、またはその他の形で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. CanDeclareGlobalVar(variableEnv, funcName)をfuncDefinableとする。
          2. そうでなければ、
            1. funcDefinablefalseとする。
        6. そうでなければ、
          1. funcDefinabletrueとする。
        7. bindingExistsfalseであり、かつfuncDefinabletrueである場合、
          1. declaredFuncOrVariableNamesfuncNameを含まない場合、
            1. variableEnvGlobal Environment Recordである場合、
              1. CreateGlobalVarBinding(variableEnv, funcName, true)を実行する。
            2. そうでなければ、
              1. variableEnv.HasBinding(funcName)をbindingExistsに設定する。
              2. bindingExistsfalseである場合、
                1. variableEnv.CreateMutableBinding(funcName, true)を実行する。
                2. variableEnv.InitializeBinding(funcName, undefined)を実行する。
            3. funcNamedeclaredFuncOrVariableNamesに追加する。
          2. FunctionDeclaration funcDeclが評価されるとき、15.2.6で提供されるFunctionDeclaration Evaluationアルゴリズムの代わりに、次のステップを実行する。
            1. 実行中の実行コンテキストのVariableEnvironmentをglobalEnvとする。
            2. 実行中の実行コンテキストのLexicalEnvironmentをblockEnvとする。
            3. blockEnv.GetBindingValue(funcName, false)をfuncObjとする。
            4. globalEnv.SetMutableBinding(funcName, funcObj, false)を実行する。
            5. unusedを返す。
  14. NOTE: variableEnvGlobal Environment Recordであり、かつグローバルオブジェクトがProxy exotic objectである場合を除き、このアルゴリズムステップ以降に異常終了は発生しない。
  15. bodyLexicallyScopedDeclarationslexicalDeclsとする。
  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. funcDeclBoundNamesの唯一の要素をfuncNameとする。
    2. lexicalEnvおよびprivateEnvを引数として、funcDeclInstantiateFunctionObjectfuncObjとする。
    3. variableEnvGlobal Environment Recordである場合、
      1. CreateGlobalFunctionBinding(variableEnv, funcName, funcObj, true)を実行する。
    4. そうでなければ、
      1. variableEnv.HasBinding(funcName)をbindingExistsとする。
      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. variableEnv.HasBinding(variableName)をbindingExistsとする。
      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です。

これは呼び出されたとき、次のstepsを実行します:

  1. numberを ? ToNumber(value) とする。
  2. numberfiniteなら、trueを返す。
  3. falseを返す。

19.2.3 isNaN ( value )

このfunctionは%isNaN% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  1. numberを ? ToNumber(value) とする。
  2. numberNaNなら、trueを返す。
  3. falseを返す。
Note

ECMAScript codeがvalue XNaNかどうかをtestするreliableな方法は、X !== Xという形式のexpressionです。そのresultは、XNaNである場合に限りtrueになります。

19.2.4 parseFloat ( string )

このfunctionは、string argumentのcontentsをdecimal literalとしてinterpretすることによってdictatedされるNumber valueをproduceします。

これは%parseFloat% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  1. inputStringを ? ToString(string) とする。
  2. trimmedStringを ! TrimString(inputString, start) とする。
  3. trimmedStringToCodePoints(trimmedString)とする。
  4. trimmedPrefixを、StrDecimalLiteralのsyntaxをsatisfiesするtrimmedのlongest prefixとする。これはtrimmed自身である場合があります。そのようなprefixがない場合、NaNを返す。
  5. parsedNumberParseText(trimmedPrefix, StrDecimalLiteral)とする。
  6. Assert: parsedNumberParse Nodeである。
  7. parsedNumberStringNumericValueを返す。
Note

このfunctionは、stringのleading portionだけをNumber valueとしてinterpretする場合があります;decimal literalのnotationの一部としてinterpretできないcode unitsは無視され、そのようなcode unitsが無視されたことを示すindicationは与えられません。

19.2.5 parseInt ( string, radix )

このfunctionは、指定されたradixに従ってstringのcontentsをinterpretすることによってdictatedされるintegral Numberをproduceします。string内のleading white spaceは無視されます。radixが0へcoerceされる場合(undefinedである場合など)、number representationが"0x"または"0X"で始まる場合を除き、10であるとassumedされます。その場合は16であるとassumedされます。radixが16である場合、number representationはoptionalに"0x"または"0X"で始まってもよいです。

これは%parseInt% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  1. inputStringを ? ToString(string) とする。
  2. trimmedStringを ! TrimString(inputString, start) とする。
  3. signを1とする。
  4. trimmedStringがemptyでなく、trimmedStringの最初のcode unitがcode unit 0x002D (HYPHEN-MINUS)であるなら、signを-1に設定する。
  5. trimmedStringがemptyでなく、trimmedStringの最初の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の最初の2つのcode unitsが"0x"または"0X"のいずれかであるなら、
      1. trimmedStringをindex 2からのtrimmedStringsubstringに設定する。
      2. radixMVを16に設定する。
  11. trimmedStringがradix-radixMV digitでないcode unitを含むなら、endtrimmedString内の最初のそのようなcode unitのindexとする;そうでなければ、endtrimmedStringのlengthとする。
  12. numberStringを0からendまでのtrimmedStringsubstringとする。
  13. numberStringがemptyなら、NaNを返す。
  14. mathIntを、radix-radixMV notationにおいてnumberStringによって表されるinteger valueとする。values 10から35のdigitsにはletters A through Zおよびa through zを使用する。(ただし、radixMV = 10であり、numberStringが20を超えるsignificant digitsを含む場合、20番目以降の各significant digitはimplementationの選択により0 digitで置き換えられてもよい;またradixMVが2、4、8、10、16、または32のいずれでもない場合、mathIntはradix-radixMV notationでnumberStringによってdenotedされるinteger valueを表す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の一部としてinterpretできないcode unitsは無視され、そのようなcode unitsが無視されたことを示すindicationは与えられません。

19.2.6 URI Handling Functions

Uniform Resource Identifiers、すなわちURIsは、resources(例えばweb pagesやfiles)およびそれらにaccessするためのtransport protocols(例えばHTTPやFTP)をInternet上でidentifyするStringsです。ECMAScript language自身は、このsectionで記述されるようにURIsをencodeおよびdecodeするfunctionsを除き、URIsを使用するためのsupportを提供しません。encodeURIおよびdecodeURIはcomplete URIsとともに動作することを意図しています;それらは、reserved charactersがspecial meaning(例えばdelimitersとして)を持つことが意図されているとassumeし、したがってencodeされません。encodeURIComponentおよびdecodeURIComponentはURIのindividual componentsとともに動作することを意図しています;それらは、reserved charactersがtextを表し、componentがcomplete URIの一部であるときspecial meaningを避けるためにencodeされなければならないとassumeします。

Note 1

reserved charactersのsetはRFC 2396に基づいており、よりrecentなRFC 3986によってintroducedされたchangesを反映していません。

Note 2

ECMAScriptの多くのimplementationsは、web pagesをmanipulateする追加のfunctionsおよびmethodsを提供します;これらのfunctionsはこのstandardのscope外です。

19.2.6.1 decodeURI ( encodedURI )

このfunctionは、encodeURI functionによってintroducedされ得る種類の各escape sequenceおよびUTF-8 encodingが、それが表すcode pointのUTF-16 encodingで置き換えられたURIのnew versionをcomputesします。encodeURIによってintroducedされ得なかったescape sequencesは置き換えられません。

これは%decodeURI% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  1. uriStringを ? ToString(encodedURI) とする。
  2. preserveEscapeSet";/?:@&=+$,#"とする。
  3. Decode(uriString, preserveEscapeSet)を返す。

19.2.6.2 decodeURIComponent ( encodedURIComponent )

このfunctionは、encodeURIComponent functionによってintroducedされ得る種類の各escape sequenceおよびUTF-8 encodingが、それが表すcode pointのUTF-16 encodingで置き換えられたURIのnew versionをcomputesします。

これは%decodeURIComponent% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  1. componentStringを ? ToString(encodedURIComponent) とする。
  2. preserveEscapeSetをempty Stringとする。
  3. Decode(componentString, preserveEscapeSet)を返す。

19.2.6.3 encodeURI ( uri )

このfunctionは、UTF-16 encoded(6.1.4)URIのnew versionをcomputesします。その中では、特定のcode pointsの各instanceが、そのcode pointのUTF-8 encodingを表す1つ、2つ、3つ、または4つのescape sequencesによって置き換えられます。

これは%encodeURI% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  1. uriStringを ? ToString(uri) とする。
  2. extraUnescaped";/?:@&=+$,#"とする。
  3. Encode(uriString, extraUnescaped)を返す。

19.2.6.4 encodeURIComponent ( uriComponent )

このfunctionは、UTF-16 encoded(6.1.4)URIのnew versionをcomputesします。その中では、特定のcode pointsの各instanceが、そのcode pointのUTF-8 encodingを表す1つ、2つ、3つ、または4つのescape sequencesによって置き換えられます。

これは%encodeURIComponent% intrinsic objectです。

これは呼び出されたとき、次のstepsを実行します:

  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. これはURI encodingおよびescapingを実行し、string6.1.4で記述されるUTF-16 encoded code pointsのsequenceとしてinterpretします。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 charactersと"-.!~*'()"string-concatenationとする。
  4. unescapedSetalwaysUnescapedextraUnescapedstring-concatenationとする。
  5. kを0とする。
  6. k < lengthの間、繰り返す
    1. codeUnitstring内のindex kにあるcode unitとする。
    2. unescapedSetcodeUnitを含むなら、
      1. kk + 1に設定する。
      2. resultresultcodeUnitstring-concatenationに設定する。
    3. そうでなければ、
      1. codePointCodePointAt(string, k)とする。
      2. codePoint.[[IsUnpairedSurrogate]]trueなら、URIError例外をthrowする。
      3. kk + codePoint.[[CodeUnitCount]]に設定する。
      4. octetscodePoint.[[CodePoint]]にUTF-8 transformationをapplyした結果のoctetsのListとする。
      5. octetsの各要素octetについて、以下を行う
        1. hexoctetのString representationとし、uppercase hexadecimal numberとしてformattedする。
        2. resultresult"%"、およびStringPad(hex, 2, "0", start)のstring-concatenationに設定する。
  7. resultを返す。
Note

percent-encodingはindividual octetsを表すために使用されるため、単一のcode pointはmultiple consecutive escape sequences(その8-bit UTF-8 code unitsのそれぞれに1つ)として表現される場合があります。

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. これはURI unescapingおよびdecodingを実行し、preserveEscapeSet内のBasic Latin charactersに対応する任意のescape sequencesをpreserveします。 It performs the following steps when called:

  1. lengthstringのlengthとする。
  2. resultをempty Stringとする。
  3. kを0とする。
  4. k < lengthの間、繰り返す
    1. codeUnitstring内のindex kにあるcode unitとする。
    2. segmentcodeUnitとする。
    3. codeUnitがcode unit 0x0025 (PERCENT SIGN)であるなら、
      1. k + 3 > lengthなら、URIError例外をthrowする。
      2. escapekからk + 3までのstringsubstringとする。
      3. firstOctetParseHexOctet(string, k + 1)とする。
      4. firstOctetintegerでないなら、URIError例外をthrowする。
      5. kk + 2に設定する。
      6. nfirstOctet内のleading 1 bitsの数とする。
      7. n = 0なら、
        1. asciiCharを、numeric valueがfirstOctetであるcode unitとする。
        2. preserveEscapeSetasciiCharを含むなら、segmentescapeに設定する;そうでなければ、segmentasciiCharに設定する。
      8. そうでなければ、
        1. n = 1またはn > 4なら、URIError例外をthrowする。
        2. octetsを« firstOctet »とする。
        3. jを1とする。
        4. j < nの間、繰り返す
          1. kk + 1に設定する。
          2. k + 3 > lengthなら、URIError例外をthrowする。
          3. string内のindex kにあるcode unitがcode unit 0x0025 (PERCENT SIGN)でないなら、URIError例外をthrowする。
          4. continuationByteParseHexOctet(string, k + 1)とする。
          5. continuationByteintegerでないなら、URIError例外をthrowする。
          6. continuationByteoctetsへappendする。
          7. kk + 2に設定する。
          8. jj + 1に設定する。
        5. Assert: octetsのlengthはnである。
        6. octetsがUnicode code pointのvalid UTF-8 encodingを含まないなら、URIError例外をthrowする。
        7. codePointを、UTF-8 transformationをoctetsにapplyして得られるcode point、すなわちoctetsのListから21-bit valueへの変換で得られるものとする。
        8. segmentUTF16EncodeCodePoint(codePoint)に設定する。
    4. resultresultsegmentstring-concatenationに設定する。
    5. kk + 1に設定する。
  5. resultを返す。
Note

RFC 3629はinvalid UTF-8 octet sequencesのdecodingをprohibitしています。例えば、invalid sequence 0xC0 0x80はcode unit 0x0000へdecodeしてはなりません。Decode algorithmのimplementationsは、そのようなinvalid sequencesにencounterしたときURIErrorをthrowすることがrequiredされます。

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内の指定されたpositionにある2つのhexadecimal charactersのsequenceをunsigned 8-bit integerへparseします。 It performs the following steps when called:

  1. lengthstringのlengthとする。
  2. Assert: position + 2 ≤ lengthである。
  3. hexDigitspositionからposition + 2までのstringsubstringとする。
  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を参照してください。