6 ECMAScript データ型と値

この仕様内のアルゴリズムは、それぞれに関連する型を持つ値を操作する。取り得る値の型は、この節で定義されるものに限られる。型はさらに ECMAScript 言語型と仕様型に分類される。

6.1 ECMAScript 言語型

ECMAScript 言語型は、ECMAScript 言語を用いて ECMAScript プログラマが直接操作する値に対応する。ECMAScript 言語型は Undefined、Null、Boolean、String、Symbol、Number、BigInt、および Object である。ECMAScript 言語値とは、ECMAScript 言語型によって特徴づけられる値である。

6.1.1 Undefined 型

Undefined 型は、undefined と呼ばれるただ 1 つの値だけを持つ。値が代入されていない変数はすべて、値 undefined を持つ。

6.1.2 Null 型

Null 型は、null と呼ばれるただ 1 つの値だけを持つ。

6.1.3 Boolean 型

Boolean 型は、truefalse と呼ばれる 2 つの値を持つ論理的実体を表す。

6.1.4 String 型

String 型は、0 個以上の 16 ビット符号なし整数値(“elements”)の順序付き列すべての集合であり、その最大長は 253 - 1 要素である。String 型は一般に、実行中の ECMAScript プログラムにおけるテキストデータを表現するために用いられ、その場合、String 内の各要素は UTF-16 コードユニット値として扱われる。各要素は、その列の中の位置を占めるものとみなされる。これらの位置には非負整数で添字が付けられる。最初の要素(存在する場合)は添字 0 にあり、次の要素(存在する場合)は添字 1 にあり、以下同様である。String の長さは、その中に含まれる要素(すなわち 16 ビット値)の個数である。空文字列の長さは 0 であり、したがって要素を含まない。

String の内容を解釈しない ECMAScript の操作は、それ以上の意味づけを行わない。String 値を解釈する操作は、各要素を単一の UTF-16 コードユニットとして扱う。しかし ECMAScript は、これらのコードユニットの値や相互関係を制限しないため、String の内容を UTF-16 で符号化された Unicode コードポイント列としてさらに解釈する操作は、不正な形式の部分列を考慮しなければならない。そのような操作は、数値が 0xD800 から 0xDBFF までの包含区間にある各コードユニット(Unicode Standard では leading surrogate、より正式には high-surrogate code unit と定義される)と、数値が 0xDC00 から 0xDFFF までの包含区間にある各コードユニット(trailing surrogate、より正式には low-surrogate code unit と定義される)に対して、次の規則に従って特別な取り扱いを適用する。

  • leading surrogate でも trailing surrogate でもないコードユニットは、同じ値を持つコードポイントとして解釈される。
  • 最初のコードユニット c1leading surrogate で、2 番目のコードユニット c2trailing surrogate である 2 つのコードユニット列は、surrogate pair であり、値 (c1 - 0xD800) × 0x400 + (c2 - 0xDC00) + 0x10000 を持つコードポイントとして解釈される。(11.1.3 を参照)
  • leading surrogate または trailing surrogate であるが、surrogate pair の一部ではないコードユニットは、同じ値を持つコードポイントとして解釈される。

関数 String.prototype.normalize22.1.3.15 を参照)は、String 値を明示的に正規化するために使用できる。String.prototype.localeCompare22.1.3.12 を参照)は内部で String 値を正規化するが、他のいかなる操作も、対象となる文字列を暗黙に正規化しない。特に明記されない限り、操作結果は言語依存および/またはロケール依存ではない。

Note

この設計の根拠は、String の実装を可能な限り単純かつ高性能に保つことにあった。ECMAScript のソーステキストが Normalized Form C であれば、Unicode エスケープシーケンスを含まない限り、文字列リテラルも正規化されることが保証される。

この仕様において、“A, B, ... の string-concatenation” という句(各引数は String 値、コードユニット、またはコードユニット列である)は、各引数のコードユニットを(順に)連結したコードユニット列を持つ String 値を表す。

inclusiveStart から exclusiveEnd までの strsubstring” という句(str は String 値またはコードユニット列であり、inclusiveStart および exclusiveEnd は整数である)は、str のうち添字 inclusiveStart から始まり、添字 exclusiveEnd の直前で終わる連続したコードユニットから成る String 値を表す(inclusiveStart = exclusiveEnd のときは空文字列である)。“to” の接尾辞が省略された場合、str の長さが exclusiveEnd の値として用いられる。

the ASCII word characters” という句は、Unicode Basic Latin ブロック内のすべての英字と数字、および U+005F(LOW LINE)のみから成る次の String 値を表す。
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_".
歴史的な理由により、これはさまざまなアルゴリズムにおいて意味を持つ。

6.1.4.1 StringIndexOf ( string, searchValue, fromIndex )

The abstract operation StringIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative integer) and returns a non-negative integer or not-found. It performs the following steps when called:

  1. lenstring の長さとする。
  2. searchValue が空文字列であり、かつ fromIndexlen なら、fromIndex を返す。
  3. searchLensearchValue の長さとする。
  4. fromIndexilen - searchLen を満たす各整数 i について、昇順で次を行う
    1. candidatestringi から i + searchLen までの substring とする。
    2. candidatesearchValue なら、i を返す。
  5. not-found を返す。
Note 1

searchValue が空文字列であり、かつ fromIndexstring の長さである場合、このアルゴリズムは fromIndex を返す。空文字列は、最後のコードユニットの後を含め、文字列内のあらゆる位置で見つかるものとして実質的に扱われる。

Note 2

このアルゴリズムは、fromIndex + searchValue の長さ > string の長さ である場合、常に not-found を返す。

6.1.4.2 StringLastIndexOf ( string, searchValue, fromIndex )

The abstract operation StringLastIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative integer) and returns a non-negative integer or not-found. It performs the following steps when called:

  1. lenstring の長さとする。
  2. searchLensearchValue の長さとする。
  3. Assert: fromIndex + searchLenlen
  4. 0 ≤ ifromIndex を満たす各整数 i について、降順で次を行う
    1. candidatestringi から i + searchLen までの substring とする。
    2. candidatesearchValue なら、i を返す。
  5. not-found を返す。
Note

searchValue が空文字列である場合、このアルゴリズムは fromIndex を返す。空文字列は、最後のコードユニットの後を含め、文字列内のあらゆる位置で見つかるものとして実質的に扱われる。

6.1.5 Symbol 型

Symbol 型は、Object のプロパティのキーとして使用できるすべての非 String 値の集合である(6.1.7)。

各 Symbol は一意であり、不変である。

各 Symbol は不変の [[Description]] 内部スロットを持ち、その値は String または undefined のいずれかである。

6.1.5.1 Well-Known Symbol

well-known symbol は、この仕様のアルゴリズムによって明示的に参照される組込み Symbol 値である。これらは通常、その値が仕様アルゴリズムの拡張ポイントとして機能するプロパティのキーとして使用される。特に指定がない限り、well-known symbol 値はすべての realm で共有される(9.3)。

この仕様では、well-known symbol は、intrinsic notation の標準記法を用いて参照される。このとき intrinsic は Table 1 に列挙された値のいずれかである。

Note
この仕様の以前の版では @@name という形式の記法が使用されていたが、現行版では %Symbol.name% を使用する。特に、次の名前が使用されていた: @@asyncIterator, @@hasInstance, @@isConcatSpreadable, @@iterator, @@match, @@matchAll, @@replace, @@search, @@species, @@split, @@toPrimitive, @@toStringTag, and @@unscopables.
Table 1: Well-known Symbols
仕様名 [[Description]] 値と目的
%Symbol.asyncIterator% "Symbol.asyncIterator" オブジェクトの既定の async iterator を返すメソッド。for-await-of 文の意味論によって呼び出される。
%Symbol.hasInstance% "Symbol.hasInstance" constructor オブジェクトが、あるオブジェクトをその constructor のインスタンスの 1 つとして認識するかどうかを決定するメソッド。instanceof 演算子の意味論によって呼び出される。
%Symbol.isConcatSpreadable% "Symbol.isConcatSpreadable" true の場合、そのオブジェクトを Array.prototype.concat によって配列要素へ平坦化すべきことを示す Boolean 値プロパティ。
%Symbol.iterator% "Symbol.iterator" オブジェクトの既定の iterator を返すメソッド。for-of 文の意味論によって呼び出される。
%Symbol.match% "Symbol.match" 正規表現を文字列に対して照合する正規表現メソッド。String.prototype.match メソッドによって呼び出される。
%Symbol.matchAll% "Symbol.matchAll" 正規表現を文字列に対して照合したマッチ結果を yield する iterator を返す正規表現メソッド。String.prototype.matchAll メソッドによって呼び出される。
%Symbol.replace% "Symbol.replace" 文字列中の一致した部分文字列を置換する正規表現メソッド。String.prototype.replace メソッドによって呼び出される。
%Symbol.search% "Symbol.search" 文字列内で正規表現に一致する位置の添字を返す正規表現メソッド。String.prototype.search メソッドによって呼び出される。
%Symbol.species% "Symbol.species" 派生オブジェクトの生成に使用される constructor 関数である function 値プロパティ。
%Symbol.split% "Symbol.split" 正規表現に一致する位置で文字列を分割する正規表現メソッド。String.prototype.split メソッドによって呼び出される。
%Symbol.toPrimitive% "Symbol.toPrimitive" オブジェクトを対応する primitive 値へ変換するメソッド。ToPrimitive 抽象操作によって呼び出される。
%Symbol.toStringTag% "Symbol.toStringTag" オブジェクトの既定の文字列表現の生成に用いられる String 値プロパティ。組込みメソッド Object.prototype.toString によって参照される。
%Symbol.unscopables% "Symbol.unscopables" その own および継承プロパティ名が、関連付けられたオブジェクトの with 環境バインディングから除外されるプロパティ名である object 値プロパティ。

6.1.6 数値型

ECMAScript には 2 つの組込み数値型がある: Number と BigInt。以下の抽象操作は、これらの数値型に対して定義される。“Result” 列には戻り値の型が示され、さらにその操作の一部の呼出しにおいて abrupt completion を返す可能性があるかどうかも示される。

Table 2: Numeric Type Operations
Operation ソース例 ... の Evaluation 意味論によって呼び出される 結果
Number::unaryMinus -x Unary - Operator Number
BigInt::unaryMinus BigInt
Number::bitwiseNOT ~x Bitwise NOT Operator ( ~ ) Number
BigInt::bitwiseNOT BigInt
Number::exponentiate x ** y Exponentiation Operator and Math.pow ( base, exponent ) Number
BigInt::exponentiate either a normal completion containing a BigInt or a throw completion
Number::multiply x * y Multiplicative Operator Number
BigInt::multiply BigInt
Number::divide x / y Multiplicative Operator Number
BigInt::divide either a normal completion containing a BigInt or a throw completion
Number::remainder x % y Multiplicative Operator Number
BigInt::remainder either a normal completion containing a BigInt or a throw completion
Number::add x ++
++ x
x + y
Postfix Increment Operator, Prefix Increment Operator, and Addition Operator ( + ) Number
BigInt::add BigInt
Number::subtract x --
-- x
x - y
Postfix Decrement Operator, Prefix Decrement Operator, and Subtraction Operator ( - ) Number
BigInt::subtract BigInt
Number::leftShift x << y Left Shift Operator ( << ) Number
BigInt::leftShift BigInt
Number::signedRightShift x >> y Signed Right Shift Operator ( >> ) Number
BigInt::signedRightShift BigInt
Number::unsignedRightShift x >>> y Unsigned Right Shift Operator ( >>> ) Number
BigInt::unsignedRightShift a throw completion
Number::lessThan x < y
x > y
x <= y
x >= y
Relational Operator, via IsLessThan ( x, y, leftFirst ) Boolean or undefined(順序付け不能な入力に対して)
BigInt::lessThan Boolean
Number::equal x == y
x != y
x === y
x !== y
Equality Operator, via IsStrictlyEqual ( x, y ) Boolean
BigInt::equal
Number::sameValue Object.is(x, y) オブジェクト内部メソッド、 via SameValue ( x, y ), 厳密な値の等価性を検査するため Boolean
Number::sameValueZero [x].includes(y) via SameValueZero ( x, y ), +0𝔽-0𝔽 の違いを無視して値の等価性を検査するため。Array、Map、Set のメソッドなどで用いられる Boolean
Number::bitwiseAND x & y Binary Bitwise Operator Number
BigInt::bitwiseAND BigInt
Number::bitwiseXOR x ^ y Number
BigInt::bitwiseXOR BigInt
Number::bitwiseOR x | y Number
BigInt::bitwiseOR BigInt
Number::toString String(x) 多くの式および組込み関数。ToString ( argument ) を介する String
BigInt::toString

数値型は一般に、精度の喪失または切り捨てなしには相互変換できないため、ECMAScript 言語はこれらの型の間で暗黙変換を提供しない。プログラマは、別の型を必要とする関数を呼び出す際には、Number および BigInt 関数を明示的に呼び出して型変換しなければならない。

Note

ECMAScript の初版およびその後の各版は、特定の演算子について、精度を失うか切り捨てる可能性のある暗黙の数値変換を提供してきた。これらのレガシーな暗黙変換は後方互換性のために維持されているが、BigInt には提供されない。これは、プログラマの誤りの機会を最小化し、将来の版において一般化された value types の選択肢を残すためである。

6.1.6.1 Number 型

Number 型は、正確に 18,437,736,874,454,810,627 個(すなわち 264 - 253 + 3)の値を持ち、IEEE Standard for Binary Floating-Point Arithmetic に規定された IEEE 754-2019 binary64 倍精度浮動小数点値を表す。ただし、IEEE Standard における 9,007,199,254,740,990 個(すなわち 253 - 2)の異なる NaN 値は、ECMAScript では単一の特別な NaN 値として表現される。(NaN 値はプログラム式 NaN によって生成されることに注意。)一部の実装では、外部コードがさまざまな NaN 値の違いを検出できる場合があるが、そのような挙動は implementation-defined である。ECMAScript コードにとって、すべての NaN 値は互いに区別不能である。

Note

Number 値が格納された後に ArrayBuffer(25.1 を参照)または SharedArrayBuffer(25.2 を参照)で観測される可能性のあるビットパターンは、ECMAScript 実装が内部的に使用するその Number 値の表現と必ずしも同じではない。

これ以外に、positive Infinity および negative Infinity と呼ばれる 2 つの特別な値がある。簡潔さのため、これらの値は説明上、それぞれ記号 +∞𝔽 および -∞𝔽 でも参照される。(これら 2 つの無限 Number 値は、プログラム式 +Infinity(または単に Infinity)および -Infinity によって生成されることに注意。)

残りの 18,437,736,874,454,810,624 個(すなわち 264 - 253)の値は finite numbers と呼ばれる。これらの半分は正の数であり、半分は負の数である。各有限の正の Number 値に対して、同じ大きさを持つ対応する負の値が存在する。

positive zeronegative zero の両方が存在することに注意。簡潔さのため、これらの値は説明上、それぞれ記号 +0𝔽 および -0𝔽 でも参照される。(この 2 つの異なる zero Number 値は、プログラム式 +0(または単に 0)および -0 によって生成されることに注意。)

18,437,736,874,454,810,622 個(すなわち 264 - 253 - 2)の有限非ゼロ値は、2 種類に分かれる。

そのうち 18,428,729,675,200,069,632 個(すなわち 264 - 254)は正規化されており、次の形を持つ。

s × m × 2e

ここで s は 1 または -1、m は 252(inclusive)から 253(exclusive)までの区間にある整数、e は -1074 から 971 までの包含区間にある整数である。

残りの 9,007,199,254,740,990 個(すなわち 253 - 2)の値は非正規化されており、次の形を持つ。

s × m × 2e

ここで s は 1 または -1、m は 0(exclusive)から 252(exclusive)までの区間にある整数、e は -1074 である。

大きさが 253 以下のすべての正負整数は Number 型で表現可能であることに注意。整数 0 は Number 型において 2 つの表現を持つ: +0𝔽-0𝔽 である。

有限数は、それが非ゼロであり、(上に示した 2 つの形式のいずれかで)それを表すために用いられる整数 m が奇数である場合、odd significand を持つ。それ以外の場合、それは even significand を持つ。

この仕様において、“xNumber value for” という句は、x が正確な実数の数学的量(π のような無理数である場合もある)を表すとき、次の方法で選ばれた Number 値を意味する。Number 型の有限値すべての集合を考え、そこから -0𝔽 を除き、さらに Number 型では表現できない 2 つの追加値、すなわち 21024(これは +1 × 253 × 2971)および -21024(これは -1 × 253 × 2971)を加える。この集合の中から、値として x に最も近い要素を選ぶ。集合の 2 つの値が同じだけ近い場合は、even significand を持つ方が選ばれる。この目的のために、追加された 2 つの値 21024 および -21024 は even significand を持つものとみなされる。最後に、21024 が選ばれた場合はそれを +∞𝔽 に置き換え、-21024 が選ばれた場合はそれを -∞𝔽 に置き換える。+0𝔽 が選ばれた場合は、x < 0 のときに限り -0𝔽 に置き換える。それ以外に選ばれた値は変更せずに用いる。結果が x の Number value である。(この手続きは IEEE 754-2019 の roundTiesToEven モードの挙動と正確に一致する。)

+∞ の Number value は +∞𝔽 であり、-∞ の Number value は -∞𝔽 である。

一部の ECMAScript 演算子は、-231 から 231 - 1 までの包含区間や、0 から 216 - 1 までの包含区間のような、特定の範囲の整数のみを扱う。これらの演算子は Number 型の任意の値を受け入れるが、まずそのような各値を期待される範囲内の整数値に変換する。7.1 における数値変換操作の説明を参照。

6.1.6.1.1 Number::unaryMinus ( x )

The abstract operation Number::unaryMinus takes argument x (a Number) and returns a Number. It performs the following steps when called:

  1. xNaN なら、NaN を返す。
  2. x の negation を返す。すなわち、同じ大きさで符号が反対の Number を計算する。

6.1.6.1.2 Number::bitwiseNOT ( x )

The abstract operation Number::bitwiseNOT takes argument x (a Number) and returns an integral Number. It performs the following steps when called:

  1. oldValue を ! ToInt32(x) とする。
  2. oldValue の bitwise complement を返す。結果の数学的値は 32 ビット 2 の補数ビット列として正確に表現可能である。

6.1.6.1.3 Number::exponentiate ( base, exponent )

The abstract operation Number::exponentiate takes arguments base (a Number) and exponent (a Number) and returns a Number. baseexponent 乗した結果を表す implementation-approximated な値を返す。 It performs the following steps when called:

  1. exponentNaN なら、NaN を返す。
  2. exponent+0𝔽 または -0𝔽 のいずれかであるなら、1𝔽 を返す。
  3. baseNaN なら、NaN を返す。
  4. base+∞𝔽 なら、
    1. exponent > +0𝔽 なら、+∞𝔽 を返す。
    2. +0𝔽 を返す。
  5. base-∞𝔽 なら、
    1. exponent > +0𝔽 なら、
      1. exponent が奇数の integral Number なら、-∞𝔽 を返す。
      2. +∞𝔽 を返す。
    2. exponent が奇数の integral Number なら、-0𝔽 を返す。
    3. +0𝔽 を返す。
  6. base+0𝔽 なら、
    1. exponent > +0𝔽 なら、+0𝔽 を返す。
    2. +∞𝔽 を返す。
  7. base-0𝔽 なら、
    1. exponent > +0𝔽 なら、
      1. exponent が奇数の integral Number なら、-0𝔽 を返す。
      2. +0𝔽 を返す。
    2. exponent が奇数の integral Number なら、-∞𝔽 を返す。
    3. +∞𝔽 を返す。
  8. Assert: basefinite であり、+0𝔽 でも -0𝔽 でもない。
  9. exponent+∞𝔽 なら、
    1. abs((base)) > 1 なら、+∞𝔽 を返す。
    2. abs((base)) = 1 なら、NaN を返す。
    3. +0𝔽 を返す。
  10. exponent-∞𝔽 なら、
    1. abs((base)) > 1 なら、+0𝔽 を返す。
    2. abs((base)) = 1 なら、NaN を返す。
    3. +∞𝔽 を返す。
  11. Assert: exponentfinite であり、+0𝔽 でも -0𝔽 でもない。
  12. base < -0𝔽 かつ exponentintegral Number でないなら、NaN を返す。
  13. (base) を (exponent) 乗した結果を表す implementation-approximated な Number 値を返す。
Note

base1𝔽 または -1𝔽exponent+∞𝔽 または -∞𝔽 の場合、または base1𝔽exponentNaN の場合の base ** exponent の結果は、IEEE 754-2019 と異なる。ECMAScript 初版はこの演算に対して NaN を結果として規定したが、その後の IEEE 754 の改訂では 1𝔽 が規定された。歴史的な ECMAScript の挙動は互換性の理由から維持されている。

6.1.6.1.4 Number::multiply ( x, y )

The abstract operation Number::multiply takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmetic の規則に従って乗算を行い、xy の積を生成する。 It performs the following steps when called:

  1. xNaN または yNaN なら、NaN を返す。
  2. x+∞𝔽 または -∞𝔽 のいずれかなら、
    1. y+0𝔽 または -0𝔽 のいずれかなら、NaN を返す。
    2. y > +0𝔽 なら、x を返す。
    3. -x を返す。
  3. y+∞𝔽 または -∞𝔽 のいずれかなら、
    1. x+0𝔽 または -0𝔽 のいずれかなら、NaN を返す。
    2. x > +0𝔽 なら、y を返す。
    3. -y を返す。
  4. x-0𝔽 なら、
    1. y-0𝔽 または y < -0𝔽 なら、+0𝔽 を返す。
    2. -0𝔽 を返す。
  5. y-0𝔽 なら、
    1. x < -0𝔽 なら、+0𝔽 を返す。
    2. -0𝔽 を返す。
  6. 𝔽((x) × (y)) を返す。
Note

有限精度の乗算は可換であるが、常に結合的とは限らない。

6.1.6.1.5 Number::divide ( x, y )

The abstract operation Number::divide takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmetic の規則に従って除算を行い、x を被除数、y を除数として、その商を生成する。 It performs the following steps when called:

  1. xNaN または yNaN なら、NaN を返す。
  2. x+∞𝔽 または -∞𝔽 のいずれかなら、
    1. y+∞𝔽 または -∞𝔽 のいずれかなら、NaN を返す。
    2. y+0𝔽 または y > +0𝔽 なら、x を返す。
    3. -x を返す。
  3. y+∞𝔽 なら、
    1. x+0𝔽 または x > +0𝔽 なら、+0𝔽 を返す。
    2. -0𝔽 を返す。
  4. y-∞𝔽 なら、
    1. x+0𝔽 または x > +0𝔽 なら、-0𝔽 を返す。
    2. +0𝔽 を返す。
  5. x+0𝔽 または -0𝔽 のいずれかなら、
    1. y+0𝔽 または -0𝔽 のいずれかなら、NaN を返す。
    2. y > +0𝔽 なら、x を返す。
    3. -x を返す。
  6. y+0𝔽 なら、
    1. x > +0𝔽 なら、+∞𝔽 を返す。
    2. -∞𝔽 を返す。
  7. y-0𝔽 なら、
    1. x > +0𝔽 なら、-∞𝔽 を返す。
    2. +∞𝔽 を返す。
  8. 𝔽((x) / (y)) を返す。

6.1.6.1.6 Number::remainder ( n, d )

The abstract operation Number::remainder takes arguments n (a Number) and d (a Number) and returns a Number. オペランドの暗黙の除算から得られる剰余を返す。ここで n は被除数、d は除数である。 It performs the following steps when called:

  1. nNaN または dNaN なら、NaN を返す。
  2. n+∞𝔽 または -∞𝔽 のいずれかなら、NaN を返す。
  3. d+∞𝔽 または -∞𝔽 のいずれかなら、n を返す。
  4. d+0𝔽 または -0𝔽 のいずれかなら、NaN を返す。
  5. n+0𝔽 または -0𝔽 のいずれかなら、n を返す。
  6. Assert: n および dfinite かつ非ゼロである。
  7. quotient(n) / (d) とする。
  8. qtruncate(quotient) とする。
  9. r(n) - ((d) × q) とする。
  10. r = 0 かつ n < -0𝔽 なら、-0𝔽 を返す。
  11. 𝔽(r) を返す。
Note 1

C および C++ では、remainder 演算子は整数オペランドのみを受け付ける。ECMAScript では浮動小数点オペランドも受け付ける。

Note 2
% 演算子によって計算される浮動小数点 remainder 演算の結果は、IEEE 754-2019 で定義される “remainder” 演算と同じではない。IEEE 754-2019 の “remainder” 演算は、切り捨て除算ではなく丸め除算から remainder を計算するため、その挙動は通常の integer remainder 演算子の挙動とは類似しない。その代わり、ECMAScript 言語は浮動小数点演算における % を、Java の integer remainder 演算子と類似した形で振る舞うよう定義している。これは C ライブラリ関数 fmod と比較できる。

6.1.6.1.7 Number::add ( x, y )

The abstract operation Number::add takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmetic の規則に従って加算を行い、引数の和を生成する。 It performs the following steps when called:

  1. xNaN または yNaN なら、NaN を返す。
  2. x+∞𝔽y-∞𝔽 なら、NaN を返す。
  3. x-∞𝔽y+∞𝔽 なら、NaN を返す。
  4. x+∞𝔽 または -∞𝔽 のいずれかなら、x を返す。
  5. y+∞𝔽 または -∞𝔽 のいずれかなら、y を返す。
  6. Assert: xy はどちらも finite である。
  7. x-0𝔽y-0𝔽 なら、-0𝔽 を返す。
  8. 𝔽((x) + (y)) を返す。
Note

有限精度の加算は可換であるが、常に結合的とは限らない。

6.1.6.1.8 Number::subtract ( x, y )

The abstract operation Number::subtract takes arguments x (a Number) and y (a Number) and returns a Number. 減算を行い、オペランドの差を生成する。x は被減数であり、y は減数である。 It performs the following steps when called:

  1. Number::add(x, Number::unaryMinus(y)) を返す。
Note

x - yx + (-y) と同じ結果を生成することは常に成り立つ。

6.1.6.1.9 Number::leftShift ( x, y )

The abstract operation Number::leftShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. lNum を ! ToInt32(x) とする。
  2. rNum を ! ToUint32(y) とする。
  3. shiftCount(rNum) modulo 32 とする。
  4. lNumshiftCount ビット左シフトした結果を返す。結果の数学的値は 32 ビット 2 の補数ビット列として正確に表現可能である。

6.1.6.1.10 Number::signedRightShift ( x, y )

The abstract operation Number::signedRightShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. lNum を ! ToInt32(x) とする。
  2. rNum を ! ToUint32(y) とする。
  3. shiftCount(rNum) modulo 32 とする。
  4. lNumshiftCount ビット符号拡張右シフトした結果を返す。最上位ビットは伝播される。結果の数学的値は 32 ビット 2 の補数ビット列として正確に表現可能である。

6.1.6.1.11 Number::unsignedRightShift ( x, y )

The abstract operation Number::unsignedRightShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. lNum を ! ToUint32(x) とする。
  2. rNum を ! ToUint32(y) とする。
  3. shiftCount(rNum) modulo 32 とする。
  4. lNumshiftCount ビットゼロ埋め右シフトした結果を返す。空いたビットはゼロで埋められる。結果の数学的値は 32 ビット符号なしビット列として正確に表現可能である。

6.1.6.1.12 Number::lessThan ( x, y )

The abstract operation Number::lessThan takes arguments x (a Number) and y (a Number) and returns a Boolean or undefined. It performs the following steps when called:

  1. xNaN なら、undefined を返す。
  2. yNaN なら、undefined を返す。
  3. xy なら、false を返す。
  4. x+0𝔽y-0𝔽 なら、false を返す。
  5. x-0𝔽y+0𝔽 なら、false を返す。
  6. x+∞𝔽 なら、false を返す。
  7. y+∞𝔽 なら、true を返す。
  8. y-∞𝔽 なら、false を返す。
  9. x-∞𝔽 なら、true を返す。
  10. Assert: xyfinite である。
  11. (x) < (y) なら、true を返す。
  12. false を返す。

6.1.6.1.13 Number::equal ( x, y )

The abstract operation Number::equal takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:

  1. xNaN なら、false を返す。
  2. yNaN なら、false を返す。
  3. xy なら、true を返す。
  4. x+0𝔽y-0𝔽 なら、true を返す。
  5. x-0𝔽y+0𝔽 なら、true を返す。
  6. false を返す。

6.1.6.1.14 Number::sameValue ( x, y )

The abstract operation Number::sameValue takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:

  1. xNaNyNaN なら、true を返す。
  2. x+0𝔽y-0𝔽 なら、false を返す。
  3. x-0𝔽y+0𝔽 なら、false を返す。
  4. xy なら、true を返す。
  5. false を返す。

6.1.6.1.15 Number::sameValueZero ( x, y )

The abstract operation Number::sameValueZero takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:

  1. xNaNyNaN なら、true を返す。
  2. x+0𝔽y-0𝔽 なら、true を返す。
  3. x-0𝔽y+0𝔽 なら、true を返す。
  4. xy なら、true を返す。
  5. false を返す。

6.1.6.1.16 NumberBitwiseOp ( op, x, y )

The abstract operation NumberBitwiseOp takes arguments op (&, ^, or |), x (a Number), and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. lNum を ! ToInt32(x) とする。
  2. rNum を ! ToInt32(y) とする。
  3. lBits(lNum) を表す 32 ビット 2 の補数ビット列とする。
  4. rBits(rNum) を表す 32 ビット 2 の補数ビット列とする。
  5. op& の場合、
    1. resultlBitsrBits にビット単位の AND 演算を適用した結果とする。
  6. Else if op^ の場合、
    1. resultlBitsrBits にビット単位の排他的 OR(XOR)演算を適用した結果とする。
  7. Else,
    1. Assert: op| である。
    2. resultlBitsrBits にビット単位の包含的 OR 演算を適用した結果とする。
  8. 32 ビット 2 の補数ビット列 result が表す整数の Number value を返す。

6.1.6.1.17 Number::bitwiseAND ( x, y )

The abstract operation Number::bitwiseAND takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. NumberBitwiseOp(&, x, y) を返す。

6.1.6.1.18 Number::bitwiseXOR ( x, y )

The abstract operation Number::bitwiseXOR takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. NumberBitwiseOp(^, x, y) を返す。

6.1.6.1.19 Number::bitwiseOR ( x, y )

The abstract operation Number::bitwiseOR takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. NumberBitwiseOp(|, x, y) を返す。

6.1.6.1.20 Number::toString ( x, radix )

The abstract operation Number::toString takes arguments x (a Number) and radix (an integer in the inclusive interval from 2 to 36) and returns a String. x を基数 radix の位取り記数法を用いた String として表す。基数 r による数の表現で使用される数字は、"0123456789abcdefghijklmnopqrstuvwxyz" の先頭 r 個のコードユニットから順に取られる。大きさが 1𝔽 以上の数の表現には、先頭のゼロは決して含まれない。 It performs the following steps when called:

  1. xNaN なら、"NaN" を返す。
  2. x+0𝔽 または -0𝔽 のいずれかなら、"0" を返す。
  3. x < -0𝔽 なら、"-"Number::toString(-x, radix) の string-concatenation を返す。
  4. x+∞𝔽 なら、"Infinity" を返す。
  5. n, k, s を、k ≥ 1、radixk - 1s < radixk𝔽(s × radixn - k) が x であり、かつ k が可能な限り小さくなるような整数とする。k は基数 radix による s の表現における桁数であり、sradix で割り切れず、また s の最下位桁はこれらの条件によって必ずしも一意に決まらないことに注意。
  6. radix ≠ 10 または n が -5 から 21 までの包含区間にあるなら、
    1. nk なら、
      1. 次の string-concatenation を返す:
        • 基数 radix による s の表現の k 桁のコードユニット
        • コードユニット 0x0030(DIGIT ZERO)の n - k 回の出現
    2. n > 0 なら、
      1. 次の string-concatenation を返す:
        • 基数 radix による s の表現の上位 n 桁のコードユニット
        • コードユニット 0x002E(FULL STOP)
        • 基数 radix による s の表現の残り k - n 桁のコードユニット
    3. Assert: n ≤ 0。
    4. 次の string-concatenation を返す:
      • コードユニット 0x0030(DIGIT ZERO)
      • コードユニット 0x002E(FULL STOP)
      • コードユニット 0x0030(DIGIT ZERO)の -n 回の出現
      • 基数 radix による s の表現の k 桁のコードユニット
  7. NOTE: この場合、入力は 1.2e+3 のような科学的 E 記法で表される。
  8. Assert: radix は 10 である。
  9. n < 0 なら、
    1. exponentSign をコードユニット 0x002D(HYPHEN-MINUS)とする。
  10. Else,
    1. exponentSign をコードユニット 0x002B(PLUS SIGN)とする。
  11. k = 1 なら、
    1. 次の string-concatenation を返す:
      • s の単一桁のコードユニット
      • コードユニット 0x0065(LATIN SMALL LETTER E)
      • exponentSign
      • abs(n - 1) の十進表現のコードユニット
  12. 次の string-concatenation を返す:
    • s の十進表現の最上位桁のコードユニット
    • コードユニット 0x002E(FULL STOP)
    • s の十進表現の残り k - 1 桁のコードユニット
    • コードユニット 0x0065(LATIN SMALL LETTER E)
    • exponentSign
    • abs(n - 1) の十進表現のコードユニット
Note 1

以下の観察は、実装にとって有用な指針となりうるが、この Standard の規範的要件の一部ではない。

  • x が -0𝔽 以外の任意の Number 値であるなら、ToNumber(ToString(x)) は x である。
  • s の最下位桁は、手順 5 に列挙された要件によって常に一意に決まるわけではない。
Note 2

上記の規則で要求されるより高精度な変換を提供する実装については、手順 5 の次の代替版を指針として用いることが推奨される。

  1. n, k, s を、k ≥ 1、radixk - 1s < radixk𝔽(s × radixn - k) が x であり、かつ k が可能な限り小さくなるような整数とする。s に複数の候補がある場合、s × radixn - k(x) に最も近くなるような s を選ぶ。そのような s が 2 つある場合は、偶数である方を選ぶ。k は基数 radix による s の表現における桁数であり、sradix で割り切れないことに注意。
Note 3

ECMAScript の実装者にとって、浮動小数点数の二進数から十進数への変換に関して David M. Gay によって書かれた論文とコードは有用である可能性がある。

Gay, David M. Correctly Rounded Binary-Decimal and Decimal-Binary Conversions. Numerical Analysis, Manuscript 90-10. AT&T Bell Laboratories (Murray Hill, New Jersey). 30 November 1990. Available as
https://ampl.com/_archive/first-website/REFS/rounding.pdf. 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.

6.1.6.2 BigInt 型

BigInt 型は整数値を表す。その値は任意の大きさを取りうるものであり、特定のビット幅には制限されない。一般に、特に注記がない限り、各演算は数学的に正確な答えを返すよう設計されている。二項演算において、BigInt は 2 の補数の二進文字列として振る舞い、負数は左側に無限にビットが立っているものとして扱われる。

6.1.6.2.1 BigInt::unaryMinus ( x )

The abstract operation BigInt::unaryMinus takes argument x (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x = 0 なら、0 を返す。
  2. -x を返す。

6.1.6.2.2 BigInt::bitwiseNOT ( x )

The abstract operation BigInt::bitwiseNOT takes argument x (a BigInt) and returns a BigInt. x の 1 の補数を返す。 It performs the following steps when called:

  1. -x - 1 を返す。

6.1.6.2.3 BigInt::exponentiate ( base, exponent )

The abstract operation BigInt::exponentiate takes arguments base (a BigInt) and exponent (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. exponent < 0 なら、RangeError 例外を投げる。
  2. base = 0 かつ exponent = 0 なら、1 を返す。
  3. baseexponent 乗を返す。

6.1.6.2.4 BigInt::multiply ( x, y )

The abstract operation BigInt::multiply takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x × y を返す。
Note
結果のビット幅が入力よりはるかに大きくなっても、正確な数学的答えが返される。

6.1.6.2.5 BigInt::divide ( x, y )

The abstract operation BigInt::divide takes arguments x (a BigInt) and y (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. y = 0 なら、RangeError 例外を投げる。
  2. quotient(x) / (y) とする。
  3. (truncate(quotient)) を返す。

6.1.6.2.6 BigInt::remainder ( n, d )

The abstract operation BigInt::remainder takes arguments n (a BigInt) and d (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. d = 0 なら、RangeError 例外を投げる。
  2. n = 0 なら、0 を返す。
  3. quotient(n) / (d) とする。
  4. q(truncate(quotient)) とする。
  5. n - (d × q) を返す。
Note
結果の符号は被除数の符号である。

6.1.6.2.7 BigInt::add ( x, y )

The abstract operation BigInt::add takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x + y を返す。

6.1.6.2.8 BigInt::subtract ( x, y )

The abstract operation BigInt::subtract takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x - y を返す。

6.1.6.2.9 BigInt::leftShift ( x, y )

The abstract operation BigInt::leftShift takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. y < 0 の場合、
    1. (floor((x) / 2-(y))) を返す。
  2. x × 2y を返す。
Note
ここでの意味論は、BigInt を無限長の 2 の補数二進数字列として扱う bitwise shift と等価であるべきである。

6.1.6.2.10 BigInt::signedRightShift ( x, y )

The abstract operation BigInt::signedRightShift takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigInt::leftShift(x, -y) を返す。

6.1.6.2.11 BigInt::unsignedRightShift ( x, y )

The abstract operation BigInt::unsignedRightShift takes arguments x (a BigInt) and y (a BigInt) and returns a throw completion. It performs the following steps when called:

  1. TypeError 例外を投げる。

6.1.6.2.12 BigInt::lessThan ( x, y )

The abstract operation BigInt::lessThan takes arguments x (a BigInt) and y (a BigInt) and returns a Boolean. It performs the following steps when called:

  1. (x) < (y) なら、true を返す。
  2. false を返す。

6.1.6.2.13 BigInt::equal ( x, y )

The abstract operation BigInt::equal takes arguments x (a BigInt) and y (a BigInt) and returns a Boolean. It performs the following steps when called:

  1. (x) = (y) なら、true を返す。
  2. false を返す。

6.1.6.2.14 BinaryAnd ( x, y )

The abstract operation BinaryAnd takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:

  1. x = 1 かつ y = 1 なら、1 を返す。
  2. 0 を返す。

6.1.6.2.15 BinaryOr ( x, y )

The abstract operation BinaryOr takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:

  1. x = 1 または y = 1 なら、1 を返す。
  2. 0 を返す。

6.1.6.2.16 BinaryXor ( x, y )

The abstract operation BinaryXor takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:

  1. x = 1 かつ y = 0 なら、1 を返す。
  2. x = 0 かつ y = 1 なら、1 を返す。
  3. 0 を返す。

6.1.6.2.17 BigIntBitwiseOp ( op, x, y )

The abstract operation BigIntBitwiseOp takes arguments op (&, ^, or |), x (a BigInt), and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x(x) に設定する。
  2. y(y) に設定する。
  3. result を 0 とする。
  4. shift を 0 とする。
  5. (x = 0 または x = -1) かつ (y = 0 または y = -1) になるまで繰り返す。
    1. xDigitx modulo 2 とする。
    2. yDigity modulo 2 とする。
    3. op& の場合、
      1. resultresult + 2shift × BinaryAnd(xDigit, yDigit) に設定する。
    4. Else if op| の場合、
      1. resultresult + 2shift × BinaryOr(xDigit, yDigit) に設定する。
    5. Else,
      1. Assert: op^ である。
      2. resultresult + 2shift × BinaryXor(xDigit, yDigit) に設定する。
    6. shiftshift + 1 に設定する。
    7. x を (x - xDigit) / 2 に設定する。
    8. y を (y - yDigit) / 2 に設定する。
  6. op& の場合、
    1. tmpBinaryAnd(x modulo 2, y modulo 2) とする。
  7. Else if op| の場合、
    1. tmpBinaryOr(x modulo 2, y modulo 2) とする。
  8. Else,
    1. Assert: op^ である。
    2. tmpBinaryXor(x modulo 2, y modulo 2) とする。
  9. tmp ≠ 0 の場合、
    1. resultresult - 2shift に設定する。
    2. NOTE: これにより符号が拡張される。
  10. result の BigInt value を返す。

6.1.6.2.18 BigInt::bitwiseAND ( x, y )

The abstract operation BigInt::bitwiseAND takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigIntBitwiseOp(&, x, y) を返す。

6.1.6.2.19 BigInt::bitwiseXOR ( x, y )

The abstract operation BigInt::bitwiseXOR takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigIntBitwiseOp(^, x, y) を返す。

6.1.6.2.20 BigInt::bitwiseOR ( x, y )

The abstract operation BigInt::bitwiseOR takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigIntBitwiseOp(|, x, y) を返す。

6.1.6.2.21 BigInt::toString ( x, radix )

The abstract operation BigInt::toString takes arguments x (a BigInt) and radix (an integer in the inclusive interval from 2 to 36) and returns a String. x を基数 radix の位取り記数法を用いた String として表す。基数 r による BigInt の表現に使われる数字は、"0123456789abcdefghijklmnopqrstuvwxyz" の先頭 r 個のコードユニットから順に取られる。0 以外の BigInt の表現には先頭のゼロは決して含まれない。 It performs the following steps when called:

  1. x < 0 なら、"-"BigInt::toString(-x, radix) の string-concatenation を返す。
  2. 基数 radix による x の表現から成る String 値を返す。

6.1.7 Object 型

Object 型の各インスタンスは、単に “an Object” とも呼ばれ、プロパティの集合を表す。各プロパティは、data property または accessor property のいずれかである。

  • data property は、キー値を ECMAScript 言語値および Boolean 属性の集合と関連付ける。
  • accessor property は、キー値を 1 つまたは 2 つの accessor function および Boolean 属性の集合と関連付ける。accessor function は、そのプロパティに関連付けられた ECMAScript 言語値を格納または取得するために使用される。

オブジェクトのプロパティは、property key を用いて一意に識別される。property key は String または Symbol のいずれかである。空文字列を含むすべての String および Symbol は property key として有効である。property name は、String である property key である。

integer index とは、CanonicalNumericIndexString(n) が +0𝔽 から 𝔽(253 - 1) までの包含区間にある integral Number を返すような property name n である。array index とは、CanonicalNumericIndexString(n) が +0𝔽 から 𝔽(232 - 2) までの包含区間にある integral Number を返すような integer index n である。

Note

すべての非負 safe integer は対応する integer index を持つ。232 - 1 を除くすべての 32 ビット符号なし整数は対応する array index を持つ。"-0"integer index でも array index でもない。

property key は、プロパティおよびその値へアクセスするために用いられる。プロパティへのアクセスには 2 種類あり、それぞれ値の取得と代入に対応する get および set である。get および set によってアクセス可能なプロパティには、オブジェクトに直接属する own properties と、プロパティ継承関係を通じて関連する別のオブジェクトから提供される inherited properties の両方が含まれる。継承されたプロパティは、その関連オブジェクトの own property でも inherited property でもありうる。オブジェクトの各 own property は、それぞれ、そのオブジェクトの他の own property のキー値と異なるキー値を持たなければならない。

すべてのオブジェクトは論理的にはプロパティの集合であるが、プロパティへのアクセスおよび操作に関する意味論が異なる複数の形式のオブジェクトが存在する。オブジェクトの複数の形式の定義については 6.1.7.2 を参照。

さらに、一部のオブジェクトは callable であり、これらは functions または function objects と呼ばれ、以下でさらに説明される。ECMAScript におけるすべての function は Object 型のメンバである。

6.1.7.1 プロパティ属性

属性は、この仕様において、Table 3 に記述される Object プロパティの状態を定義および説明するために使用される。明示的に指定されない限り、各属性の初期値はその Default Value である。

Table 3: Attributes of an Object property
属性名 その属性が存在するプロパティの種類 値域 既定値 説明
[[Value]] data property an ECMAScript language value undefined そのプロパティに対する get アクセスによって取得される値。
[[Writable]] data property a Boolean false false の場合、[[Set]] を用いてそのプロパティの [[Value]] 属性を変更しようとする ECMAScript コードの試みは成功しない。
[[Get]] accessor property an Object or undefined undefined 値が Object であるなら、それは function object でなければならない。その function の [[Call]] 内部メソッド(Table 5)は、そのプロパティに対して get アクセスが行われるたびに、空の引数リストで呼び出され、プロパティ値を取得する。
[[Set]] accessor property an Object or undefined undefined 値が Object であるなら、それは function object でなければならない。その function の [[Call]] 内部メソッド(Table 5)は、そのプロパティに対して set アクセスが行われるたびに、代入された値を唯一の引数とする引数リストで呼び出される。プロパティの [[Set]] 内部メソッドの効果は、その後のそのプロパティの [[Get]] 内部メソッド呼出しによって返される値に影響してもよいし、影響しなくてもよい。
[[Enumerable]] data property or accessor property a Boolean false true の場合、そのプロパティは for-in 列挙(14.7.5 を参照)によって列挙される。そうでない場合、そのプロパティは non-enumerable であると言われる。
[[Configurable]] data property or accessor property a Boolean false false の場合、そのプロパティの削除、そのプロパティを data property から accessor property に変更すること、または accessor property から data property に変更すること、あるいは属性に対する変更(既存の [[Value]] を置き換えるか [[Writable]]false に設定すること以外)は失敗する。

6.1.7.2 Object 内部メソッドと内部スロット

ECMAScript におけるオブジェクトの実際の意味論は、internal methods と呼ばれるアルゴリズムによって規定される。ECMAScript エンジン内の各オブジェクトは、その実行時の挙動を定義する内部メソッドの集合と関連付けられている。これらの内部メソッドは ECMAScript 言語の一部ではない。これらは純粋に説明のためにこの仕様で定義される。しかし、ECMAScript の実装内の各オブジェクトは、それに関連付けられた内部メソッドに従って振る舞わなければならない。これをどのように正確に達成するかは、実装によって決定される。

内部メソッド名は多相的である。これは、共通の内部メソッド名が適用されたときに、異なるオブジェクト値が異なるアルゴリズムを実行しうることを意味する。内部メソッドが呼び出される実際のオブジェクトは、その呼出しの “target” である。実行時に、あるアルゴリズムの実装が、そのオブジェクトがサポートしていない内部メソッドを使用しようとした場合、TypeError 例外が投げられる。

内部スロットは、オブジェクト、Symbol、または Private Name に関連付けられ、さまざまな ECMAScript 仕様アルゴリズムで使用される内部状態に対応する。内部スロットはオブジェクトプロパティではなく、継承もされない。特定の内部スロット仕様に応じて、そのような状態は任意の ECMAScript 言語型の値、または特定の ECMAScript 仕様型の値から成ってよい。明示的に特に指定されない限り、内部スロットはオブジェクト、Symbol、または Private Name を生成する過程の一部として割り当てられ、動的に追加することはできない。特に指定されない限り、内部スロットの初期値は値 undefined である。この仕様内のさまざまなアルゴリズムは、内部スロットを持つ値を生成する。しかし、ECMAScript 言語は内部スロットを直接操作する方法を提供しない。

すべてのオブジェクトは [[PrivateElements]] という名前の内部スロットを持ち、これは PrivateElementsList である。この List は、そのオブジェクトの private field、method、および accessor の値を表す。初期状態では空の List である。

内部メソッドおよび内部スロットは、この仕様の中では二重角括弧 [[ ]] で囲まれた名前を用いて識別される。

Table 4 は、この仕様で使用される essential internal methods を要約したものであり、ECMAScript コードによって生成または操作されるすべてのオブジェクトに適用される。すべてのオブジェクトは、すべての essential internal method に対するアルゴリズムを持たなければならない。しかし、すべてのオブジェクトがそれらのメソッドに対して同じアルゴリズムを使う必要はない。

ordinary object とは、次の基準をすべて満たすオブジェクトである。

  • Table 4 に列挙された内部メソッドについて、そのオブジェクトは 10.1 で定義されたものを使用する。
  • そのオブジェクトが [[Call]] 内部メソッドを持つ場合、10.2.1 で定義されたもの、または 10.3.1 で定義されたもののいずれかを使用する。
  • そのオブジェクトが [[Construct]] 内部メソッドを持つ場合、10.2.2 で定義されたもの、または 10.3.2 で定義されたもののいずれかを使用する。

exotic object とは、ordinary object ではないオブジェクトである。

この仕様は、異なる種類の exotic object を、それらのオブジェクトの内部メソッドによって認識する。ある特定の種類の exotic object(Array exotic object や bound function exotic object など)と挙動上等価であっても、その種類に対して規定されたのと同じ内部メソッドの集合を持たないオブジェクトは、その種類の exotic object としては認識されない。

Table 4 および他の同様の表における “Signature” 列は、各内部メソッドの呼出しパターンを記述する。呼出しパターンは常に、説明的なパラメータ名を括弧で囲んだリストを含む。パラメータ名が ECMAScript 型名と同じである場合、その名前はパラメータ値に要求される型を記述する。内部メソッドが明示的に値を返す場合、そのパラメータリストの後には記号 “→” と、返される値の型名が続く。signature に使用される型名は、節 6 で定義された型に、以下の追加名を加えたものを指す。“any” は、その値が任意の ECMAScript 言語型でありうることを意味する。

内部メソッドは、そのパラメータに加えて、常にメソッド呼出しの target であるオブジェクトへアクセスできる。

内部メソッドは暗黙に Completion Record を返す。これは、その呼出しパターンに示された戻り型の値を包む normal completion、または throw completion のいずれかである。

Table 4: Essential Internal Methods
Internal Method Signature 説明
[[GetPrototypeOf]] ( ) Object | Null このオブジェクトに継承プロパティを提供するオブジェクトを決定する。null 値は継承プロパティが存在しないことを示す。
[[SetPrototypeOf]] (Object | Null) Boolean このオブジェクトを、継承プロパティを提供する別のオブジェクトと関連付ける。null を渡すことは、継承プロパティが存在しないことを示す。操作が正常に完了したことを示す true、または成功しなかったことを示す false を返す。
[[IsExtensible]] ( ) Boolean このオブジェクトに追加のプロパティを加えることが許可されているかどうかを判定する。
[[PreventExtensions]] ( ) Boolean このオブジェクトに新しいプロパティを追加できるかどうかを制御する。操作が成功した場合は true、失敗した場合は false を返す。
[[GetOwnProperty]] (propertyKey) Undefined | Property Descriptor キーが propertyKey であるこのオブジェクトの own property に対する Property Descriptor を返す。そのようなプロパティが存在しない場合は undefined を返す。
[[DefineOwnProperty]] (propertyKey, propertyDescriptor) Boolean キーが propertyKey である own property を作成または変更し、propertyDescriptor によって記述される状態を持たせる。そのプロパティが正常に作成/更新された場合は true を、そのプロパティを作成または更新できなかった場合は false を返す。
[[HasProperty]] (propertyKey) Boolean キーが propertyKey である own property または inherited property のいずれかをこのオブジェクトがすでに持っているかどうかを示す Boolean 値を返す。
[[Get]] (propertyKey, receiver) any キーが propertyKey であるプロパティの値をこのオブジェクトから返す。プロパティ値を取得するために ECMAScript コードを実行しなければならない場合、receiver はそのコードを評価するときの this 値として使用される。
[[Set]] (propertyKey, value, receiver) Boolean キーが propertyKey であるプロパティの値を value に設定する。プロパティ値を設定するために ECMAScript コードを実行しなければならない場合、receiver はそのコードを評価するときの this 値として使用される。プロパティ値が設定された場合は true、設定できなかった場合は false を返す。
[[Delete]] (propertyKey) Boolean キーが propertyKey である own property をこのオブジェクトから削除する。プロパティが削除されず、なお存在している場合は false を返す。プロパティが削除された場合、または存在しない場合は true を返す。
[[OwnPropertyKeys]] ( ) List of property keys そのオブジェクトのすべての own property key を要素として持つ List を返す。

Table 5 は、関数として呼び出されうるオブジェクトによってサポートされる追加の essential internal method を要約したものである。function object とは、[[Call]] 内部メソッドをサポートするオブジェクトである。constructor とは、[[Construct]] 内部メソッドをサポートするオブジェクトである。[[Construct]] をサポートするすべてのオブジェクトは [[Call]] もサポートしなければならない。すなわち、すべての constructorfunction object でなければならない。したがって、constructorconstructor function または constructor function object とも呼ばれる。

Table 5: Additional Essential Internal Methods of Function Objects
Internal Method Signature 説明
[[Call]] (any, a List of any) any このオブジェクトに関連付けられたコードを実行する。関数呼出し式を介して起動される。内部メソッドへの引数は this 値と、その要素が呼出し式によって関数に渡された引数である List である。この内部メソッドを実装するオブジェクトは callable である。
[[Construct]] (a List of any, Object) Object オブジェクトを生成する。new 演算子または super 呼出しを介して起動される。内部メソッドへの第 1 引数は、constructor 呼出しまたは super 呼出しの引数を要素とする List である。第 2 引数は、最初に new 演算子が適用されたオブジェクトである。この内部メソッドを実装するオブジェクトは constructors と呼ばれる。function object は必ずしも constructor ではなく、そのような非 constructor function object[[Construct]] 内部メソッドを持たない。

ordinary object および標準 exotic object に対する essential internal method の意味論は、節 10 で規定される。exotic object の内部メソッドの指定された使用が実装でサポートされていない場合、その使用は試みられた際に TypeError 例外を投げなければならない。

6.1.7.3 Essential Internal Methods の不変条件

ECMAScript エンジンの Object の Internal Methods は、以下に規定される不変条件の一覧に適合しなければならない。この仕様における ordinary ECMAScript Object およびすべての標準 exotic object は、これらの不変条件を維持する。ECMAScript Proxy object は、[[ProxyHandler]] object 上で起動された trap の結果に対する実行時検査によって、これらの不変条件を維持する。

実装によって提供される exotic object も、それらのオブジェクトに対してこれらの不変条件を維持しなければならない。これらの不変条件に違反すると、ECMAScript コードが予測不能な挙動を示したり、セキュリティ上の問題を生じさせたりする可能性がある。しかし、これらの不変条件に違反しても、実装のメモリ安全性が損なわれることは決してあってはならない。

実装は、これらの不変条件を強制することなく essential internal methods の機能を実装する代替インターフェースを提供するなどして、これらの不変条件がいかなる方法によっても回避されることを許してはならない。

定義:

  • 内部メソッドの target とは、その内部メソッドが呼び出されるオブジェクトである。
  • target は、その [[IsExtensible]] 内部メソッドから false を返すこと、またはその [[PreventExtensions]] 内部メソッドから true を返すことが観測されている場合、non-extensible である。
  • non-existent property とは、non-extensible target 上に own property として存在しないプロパティである。
  • SameValue へのすべての参照は、SameValue アルゴリズムの定義に従う。

戻り値:

任意の内部メソッドによって返される値は、次のいずれかを持つ Completion Record でなければならない。

  • [[Type]] = normal, [[Target]] = empty, および [[Value]] = その内部メソッドについて以下に示される “normal return type” の値、または
  • [[Type]] = throw, [[Target]] = empty, および [[Value]] = 任意の ECMAScript 言語値
Note 1

内部メソッドは continue completionbreak completion、または return completion を返してはならない。

[[GetPrototypeOf]] ( )

  • normal return type は Object または Null のいずれかである。
  • target が non-extensible であり、[[GetPrototypeOf]] が値 proto を返した場合、その後の [[GetPrototypeOf]] の呼出しはすべて protoSameValue である値を返すべきである。
Note 2

オブジェクトの prototype chain は有限長であるべきである(すなわち、任意のオブジェクトから始めて、その結果に [[GetPrototypeOf]] 内部メソッドを再帰的に適用すると、最終的に値 null に到達するべきである)。しかし、prototype chain に ordinary object における [[GetPrototypeOf]] の定義を使用しない exotic object が含まれている場合、この要件はオブジェクトレベルの不変条件としては強制できない。そのような循環 prototype chain は、オブジェクトプロパティへのアクセス時に無限ループを引き起こす可能性がある。

[[SetPrototypeOf]] ( proto )

  • normal return type は Boolean である。
  • target が non-extensible である場合、proto が target の観測された [[GetPrototypeOf]] 値と SameValue でない限り、[[SetPrototypeOf]]false を返さなければならない。

[[IsExtensible]] ( )

  • normal return type は Boolean である。
  • [[IsExtensible]]false を返した場合、その後の target に対するすべての [[IsExtensible]] 呼出しは false を返さなければならない。

[[PreventExtensions]] ( )

  • normal return type は Boolean である。
  • [[PreventExtensions]]true を返した場合、その後の target に対するすべての [[IsExtensible]] 呼出しは false を返さなければならず、その target は以後 non-extensible とみなされる。

[[GetOwnProperty]] ( propertyKey )

  • normal return type は Property Descriptor または Undefined のいずれかである。
  • 戻り値が Property Descriptor である場合、それは fully populated Property Descriptor でなければならない。
  • propertyKey が non-configurable かつ non-writable な own data property として記述されている場合、その後のすべての [[GetOwnProperty]] ( propertyKey ) 呼出しは、その [[Value]]propertyKey[[Value]] 属性と SameValue である Property Descriptor を返さなければならない。
  • propertyKey[[Writable]] および [[Value]] 以外の属性が時間とともに変化しうる場合、またはそのプロパティが削除されうる場合、propertyKey[[Configurable]] 属性は true でなければならない。
  • [[Writable]] 属性が false から true に変化しうる場合、[[Configurable]] 属性は true でなければならない。
  • target が non-extensible であり、かつ propertyKey が non-existent である場合、その後の target に対するすべての [[GetOwnProperty]] (propertyKey) 呼出しは propertyKey を non-existent として記述しなければならない(すなわち [[GetOwnProperty]] (propertyKey) は undefined を返さなければならない)。
Note 3

第 3 の不変条件の帰結として、あるプロパティが data property として記述され、かつ時間とともに異なる値を返しうる場合、その値を変更する仕組みが他の essential internal methods を通じて公開されていないとしても、[[Writable]] および [[Configurable]] 属性のいずれか一方または両方が true でなければならない。

[[DefineOwnProperty]] ( propertyKey, desc )

  • normal return type は Boolean である。
  • [[DefineOwnProperty]] は、propertyKey が以前に target の non-configurable own property として観測されていた場合、次のいずれかに当てはまらない限り false を返さなければならない。
    1. propertyKey が writable data property である。non-configurable な writable data property は、non-configurable な non-writable data property に変更できる。
    2. desc のすべての属性が propertyKey の属性と SameValue である。
  • [[DefineOwnProperty]] (propertyKey, desc) は、target が non-extensible であり、かつ propertyKey が non-existent own property である場合、false を返さなければならない。すなわち、non-extensible target object は新しいプロパティによって拡張できない。

[[HasProperty]] ( propertyKey )

  • normal return type は Boolean である。
  • propertyKey が以前に target の non-configurable own data property または accessor property として観測されていた場合、[[HasProperty]]true を返さなければならない。

[[Get]] ( propertyKey, receiver )

  • normal return type は任意の ECMAScript 言語型である。
  • propertyKey が以前に、値 value を持つ target の non-configurable かつ non-writable own data property として観測されていた場合、[[Get]]valueSameValue である値を返さなければならない。
  • propertyKey が以前に、[[Get]] 属性が undefined である target の non-configurable own accessor property として観測されていた場合、[[Get]] 操作は undefined を返さなければならない。

[[Set]] ( propertyKey, value, receiver )

  • normal return type は Boolean である。
  • propertyKey が以前に target の non-configurable かつ non-writable own data property として観測されていた場合、valuepropertyKey[[Value]] 属性と SameValue である場合を除き、[[Set]]false を返さなければならない。
  • propertyKey が以前に、[[Set]] 属性が undefined である target の non-configurable own accessor property として観測されていた場合、[[Set]] 操作は false を返さなければならない。

[[Delete]] ( propertyKey )

  • normal return type は Boolean である。
  • propertyKey が以前に target の non-configurable own data property または accessor property として観測されていた場合、[[Delete]]false を返さなければならない。

[[OwnPropertyKeys]] ( )

  • normal return type は List である。
  • 返される List には重複する項目が含まれていてはならない。
  • 返される List の各要素は property key でなければならない。
  • 返される List には、以前に観測されたすべての non-configurable own property のキーが少なくとも含まれていなければならない。
  • target が non-extensible である場合、返される List[[GetOwnProperty]] を用いて観測可能な target のすべての own property のキーのみを含まなければならない。

[[Call]] ( )

[[Construct]] ( )

  • normal return type は Object である。
  • target は [[Call]] 内部メソッドも持たなければならない。

6.1.7.4 Well-Known Intrinsic Object

well-known intrinsic は、この仕様のアルゴリズムによって明示的に参照され、通常 realm 固有の identity を持つ組込みオブジェクトである。特に指定がない限り、各 intrinsic object は実際には、realm ごとに 1 つずつ存在する類似オブジェクトの集合に対応する。

この仕様において、%name% のような参照は、その名前に対応する現在の realm に関連付けられた intrinsic object を意味する。%name.a.b% のような参照は、あたかも ECMAScript コードが評価される前に intrinsic object %name% の "a" プロパティの値の "b" プロパティへアクセスしたかのように意味する。現在の realm およびその intrinsic の決定方法は 9.4 に記述されている。well-known intrinsic は Table 6 に列挙されている。

Table 6: Well-Known Intrinsic Objects
Intrinsic 名 グローバル名 ECMAScript 言語との関連
%AggregateError% AggregateError AggregateError constructor20.5.7.1
%Array% Array Array constructor23.1.1
%ArrayBuffer% ArrayBuffer ArrayBuffer constructor25.1.4
%ArrayIteratorPrototype% Array Iterator object の prototype(23.1.5
%AsyncFromSyncIteratorPrototype% Async-from-Sync Iterator object の prototype(27.1.5
%AsyncFunction% async function objectconstructor27.7.1
%AsyncGeneratorFunction% async generator function objectconstructor27.4.1
%AsyncGeneratorPrototype% async generator object の prototype(27.6
%AsyncIteratorPrototype% すべての標準組込み async iterator object が間接的に継承するオブジェクト
%Atomics% Atomics Atomics object(25.4
%BigInt% BigInt BigInt constructor21.2.1
%BigInt64Array% BigInt64Array BigInt64Array constructor23.2
%BigUint64Array% BigUint64Array BigUint64Array constructor23.2
%Boolean% Boolean Boolean constructor20.3.1
%DataView% DataView DataView constructor25.3.2
%Date% Date Date constructor21.4.2
%decodeURI% decodeURI decodeURI function(19.2.6.1
%decodeURIComponent% decodeURIComponent decodeURIComponent function(19.2.6.2
%encodeURI% encodeURI encodeURI function(19.2.6.3
%encodeURIComponent% encodeURIComponent encodeURIComponent function(19.2.6.4
%Error% Error Error constructor20.5.1
%eval% eval eval function(19.2.1
%EvalError% EvalError EvalError constructor20.5.5.1
%FinalizationRegistry% FinalizationRegistry FinalizationRegistry constructor26.2.1
%Float16Array% Float16Array Float16Array constructor23.2
%Float32Array% Float32Array Float32Array constructor23.2
%Float64Array% Float64Array Float64Array constructor23.2
%ForInIteratorPrototype% For-In Iterator object の prototype(14.7.5.10
%Function% Function Function constructor20.2.1
%GeneratorFunction% generator function objectconstructor27.3.1
%GeneratorPrototype% generator object の prototype(27.5
%Int8Array% Int8Array Int8Array constructor23.2
%Int16Array% Int16Array Int16Array constructor23.2
%Int32Array% Int32Array Int32Array constructor23.2
%isFinite% isFinite isFinite function(19.2.2
%isNaN% isNaN isNaN function(19.2.3
%Iterator% Iterator Iterator constructor27.1.3.1
%IteratorHelperPrototype% Iterator Helper object の prototype(27.1.2.1
%JSON% JSON JSON object(25.5
%Map% Map Map constructor24.1.1
%MapIteratorPrototype% Map Iterator object の prototype(24.1.5
%Math% Math Math object(21.3
%Number% Number Number constructor21.1.1
%Object% Object Object constructor20.1.1
%parseFloat% parseFloat parseFloat function(19.2.4
%parseInt% parseInt parseInt function(19.2.5
%Promise% Promise Promise constructor27.2.3
%Proxy% Proxy Proxy constructor28.2.1
%RangeError% RangeError RangeError constructor20.5.5.2
%ReferenceError% ReferenceError ReferenceError constructor20.5.5.3
%Reflect% Reflect Reflect object(28.1
%RegExp% RegExp RegExp constructor22.2.4
%RegExpStringIteratorPrototype% RegExp String Iterator object の prototype(22.2.9
%Set% Set Set constructor24.2.2
%SetIteratorPrototype% Set Iterator object の prototype(24.2.6
%SharedArrayBuffer% SharedArrayBuffer SharedArrayBuffer constructor25.2.3
%String% String String constructor22.1.1
%StringIteratorPrototype% String Iterator object の prototype(22.1.5
%Symbol% Symbol Symbol constructor20.4.1
%SyntaxError% SyntaxError SyntaxError constructor20.5.5.4
%ThrowTypeError% 無条件に %TypeError% の新しいインスタンスを投げる function object
%TypedArray% すべての typed Array constructor の super class(23.2.1
%TypeError% TypeError TypeError constructor20.5.5.5
%Uint8Array% Uint8Array Uint8Array constructor23.2
%Uint8ClampedArray% Uint8ClampedArray Uint8ClampedArray constructor23.2
%Uint16Array% Uint16Array Uint16Array constructor23.2
%Uint32Array% Uint32Array Uint32Array constructor23.2
%URIError% URIError URIError constructor20.5.5.6
%WeakMap% WeakMap WeakMap constructor24.3.1
%WeakRef% WeakRef WeakRef constructor26.1.1
%WeakSet% WeakSet WeakSet constructor24.4.1
%WrapForValidIteratorPrototype% Iterator.from が返す wrapped iterator object の prototype(27.1.3.2.2.1
Note

Table 98 に追加の項目がある。

6.2 ECMAScript 仕様型

仕様型は、ECMAScript 言語構成要素および ECMAScript 言語型の意味論を記述するためにアルゴリズム内で使用されるメタ値に対応する。仕様型には、Reference RecordListCompletion RecordProperty DescriptorEnvironment RecordAbstract Closure、および Data Block が含まれる。仕様型の値は仕様上の人工物であり、ECMAScript 実装内の特定の実体に必ずしも対応しない。仕様型の値は ECMAScript 式評価の中間結果を記述するために使用されることがあるが、そのような値はオブジェクトのプロパティや ECMAScript 言語変数の値として格納することはできない。

6.2.1 Enum 仕様型

Enum は、仕様内部の値であり、ECMAScript コードから直接観測することはできない。Enum は、sans-serif 書体を用いた upper kebab case で表記される。たとえば、Completion Record[[Type]] フィールドは normalreturn、または throw のような値を取る。Enum はその名前以外の性質を持たない。enum の名前は、他の enum と区別するため以外の目的を持たず、その使用法や文脈上の意味について何も含意しない。

6.2.2 List および Record 仕様型

List 型は、new 式、関数呼出し、および単純な順序付き値リストが必要な他のアルゴリズムにおける引数リストの評価(13.3.8 を参照)を説明するために使用される。List 型の値は、個々の値を含む list 要素の単なる順序付き列である。これらの列は任意の長さを取りうる。list の要素には 0 始まりの添字を用いてランダムアクセスできる。表記上の便宜のため、配列風の構文を用いて List 要素へアクセスできる。たとえば、arguments[2] は List arguments の 3rd 要素を意味する略記である。

アルゴリズムが順序を明示せずに List の要素を反復するとき、用いられる順序は List 内の要素の順序である。

この仕様内での記法上の便宜のため、新しい List 値を表現するためにリテラル構文を用いることができる。たとえば、« 1, 2 » は、2 つの要素を持ち、それぞれが特定の値に初期化された List 値を定義する。新しい空の List は « » と表現できる。

この仕様において、“A, B, ... の list-concatenation” という句(各引数は空であってよい List である)は、各引数の要素を(順に)連結した要素を持つ新しい List 値を表す。

String の List に適用される “lexicographic code unit order に従って sorted される” という句は、短い方の文字列の長さまで各コードユニットの数値で比較し、すべて等しい場合には短い文字列を長い文字列より前に並べることを意味し、これは抽象操作 IsLessThan に記述される。

Record 型は、この仕様のアルゴリズム内におけるデータ集約を記述するために使用される。Record 型の値は、1 つ以上の名前付きフィールドから成る。各フィールドの値は ECMAScript 言語値または仕様値である。フィールド名は常に二重角括弧で囲まれる。たとえば [[Value]] である。

この仕様内での記法上の便宜のため、オブジェクトリテラルに似た構文を用いて Record 値を表現できる。たとえば、{ [[Field1]]: 42, [[Field2]]: false, [[Field3]]: empty } は、3 つのフィールドを持ち、それぞれが特定の値に初期化された Record 値を定義する。フィールド名の順序は重要ではない。明示的に列挙されていないフィールドは存在しないものとみなされる。

仕様本文およびアルゴリズムでは、ドット記法を用いて Record 値の特定フィールドを参照できる。たとえば、R が前段落で示した record であるなら、R.[[Field2]] は “R の [[Field2]] という名前のフィールド” の略記である。

よく使用される Record フィールドの組合せに対する schema には名前を付けることができ、その名前はリテラル Record 値の接頭辞として使用され、記述されている集約の具体的な種類を識別できる。たとえば: PropertyDescriptor { [[Value]]: 42, [[Writable]]: false, [[Configurable]]: true }。

6.2.3 Set および Relation 仕様型

Set 型は、メモリモデルで使用するための順序を持たない要素の集合を説明するために使用される。これは同名の ECMAScript コレクション型とは異なる。曖昧さを避けるため、この仕様では ECMAScript のコレクションのインスタンスは一貫して “Set objects” と呼ばれる。Set 型の値は単純な要素の集合であり、同一要素は 2 回以上現れない。要素は Set に追加したり、Set から削除したりできる。Set 同士は和、積、差を取ることができる。

Relation 型は、Set 上の制約を説明するために使用される。Relation 型の値は、その値域から取られた値の順序対の Set である。たとえば、Memory events 上の Relation は Memory events の順序対の集合である。Relation R と、その値域に属する 2 つの値 a および b に対して、a R b は、順序対 (a, b) が R のメンバであることを意味する略記である。ある条件に関して least Relation である Relation とは、その条件を満たす最小の Relation である。

strict partial order は、次を満たす Relation 値 R である。

  • R の定義域に属するすべての a, b, および c について:

    • a R a は成り立たず、かつ
    • a R b かつ b R c なら、a R c である。
Note 1

上の 2 つの性質は、それぞれ irreflexivity および transitivity と呼ばれる。

strict total order は、次を満たす Relation 値 R である。

  • R の定義域に属するすべての a, b, および c について:

    • ab であるか、a R b であるか、または b R a であり、かつ
    • a R a は成り立たず、かつ
    • a R b かつ b R c なら、a R c である。
Note 2

上の 3 つの性質は、それぞれ totality、irreflexivity、および transitivity と呼ばれる。

6.2.4 Completion Record 仕様型

Completion Record 仕様型は、値の実行時伝播および、非局所的な制御移動を行う文(breakcontinuereturnthrow)の挙動のような制御フローを説明するために使用される。

Completion Record は Table 7 で定義されるフィールドを持つ。

Table 7: Completion Record Fields
フィールド名 意味
[[Type]] normal, break, continue, return, or throw 発生した completion の種類。
[[Value]] Completion Record を除く任意の値 生成された値。
[[Target]] a String or empty 指向的な制御移動の target ラベル。

次の略記用語は、ときどき Completion Record を参照するために使用される。

  • normal completion は、[[Type]] の値が normal である任意の Completion Record を指す。
  • break completion は、[[Type]] の値が break である任意の Completion Record を指す。
  • continue completion は、[[Type]] の値が continue である任意の Completion Record を指す。
  • return completion は、[[Type]] の値が return である任意の Completion Record を指す。
  • throw completion は、[[Type]] の値が throw である任意の Completion Record を指す。
  • abrupt completion は、[[Type]] の値が normal 以外である任意の Completion Record を指す。
  • a normal completion containing some type of value は、その型の値を [[Value]] フィールドに持つ normal completion を指す。

この仕様で定義される callable object は、normal completion または throw completion のみを返す。他の種類の Completion Record を返すことは編集上の誤りとみなされる。

implementation-defined callable object は、normal completion または throw completion のいずれかを返さなければならない。

6.2.4.1 NormalCompletion ( value )

The abstract operation NormalCompletion takes argument value (any value except a Completion Record) and returns a normal completion. It performs the following steps when called:

  1. Completion Record { [[Type]]: normal, [[Value]]: value, [[Target]]: empty } を返す。

6.2.4.2 ThrowCompletion ( value )

The abstract operation ThrowCompletion takes argument value (an ECMAScript language value) and returns a throw completion. It performs the following steps when called:

  1. Completion Record { [[Type]]: throw, [[Value]]: value, [[Target]]: empty } を返す。

6.2.4.3 ReturnCompletion ( value )

The abstract operation ReturnCompletion takes argument value (an ECMAScript language value) and returns a return completion. It performs the following steps when called:

  1. Completion Record { [[Type]]: return, [[Value]]: value, [[Target]]: empty } を返す。

6.2.4.4 UpdateEmpty ( completionRecord, value )

The abstract operation UpdateEmpty takes arguments completionRecord (a Completion Record) and value (any value except a Completion Record) and returns a Completion Record. It performs the following steps when called:

  1. Assert: completionRecordreturn completion または throw completion のいずれかである場合、completionRecord.[[Value]]empty ではない。
  2. completionRecord.[[Value]]empty でない場合、? completionRecord を返す。
  3. Completion Record { [[Type]]: completionRecord.[[Type]], [[Value]]: value, [[Target]]: completionRecord.[[Target]] } を返す。

6.2.5 Reference Record 仕様型

Reference Record 型は、deletetypeof、代入演算子、super キーワード、およびその他の言語機能のような演算子の挙動を説明するために使用される。たとえば、代入の左側オペランドは Reference Record を生成することが期待される。

Reference Record は解決済みの名前、または(まだ解決されていない可能性のある)プロパティバインディングであり、そのフィールドは Table 8 によって定義される。

Table 8: Reference Record Fields
フィールド名 意味
[[Base]] an ECMAScript language value, an Environment Record, or unresolvable バインディングを保持する値または Environment Record[[Base]]unresolvable であることは、そのバインディングを解決できなかったことを示す。
[[ReferencedName]] an ECMAScript language value or a Private Name そのバインディングの名前。[[Base]] の値が Environment Record である場合は常に String。それ以外の場合、ToPropertyKey が実行されるまでは、String や Symbol 以外の ECMAScript 言語値である場合がある。
[[Strict]] a Boolean Reference Recordstrict mode code に由来する場合は true、そうでない場合は false
[[ThisValue]] an ECMAScript language value or empty empty でない場合、その Reference Recordsuper キーワードを用いて表現されたプロパティバインディングを表し、Super Reference Record と呼ばれる。その [[Base]] 値が Environment Record であることは決してない。その場合、[[ThisValue]] フィールドは、その Reference Record が作成された時点の this 値を保持する。

以下の抽象操作が、この仕様において Reference Record を操作するために使用される。

6.2.5.1 IsPropertyReference ( referenceRecord )

The abstract operation IsPropertyReference takes argument referenceRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. referenceRecord.[[Base]]unresolvable なら、false を返す。
  2. referenceRecord.[[Base]]Environment Record なら、false を返す。
  3. true を返す。

6.2.5.2 IsUnresolvableReference ( referenceRecord )

The abstract operation IsUnresolvableReference takes argument referenceRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. referenceRecord.[[Base]]unresolvable なら、true を返す。
  2. false を返す。

6.2.5.3 IsSuperReference ( referenceRecord )

The abstract operation IsSuperReference takes argument referenceRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. referenceRecord.[[ThisValue]]empty なら、false を返す。
  2. true を返す。

6.2.5.4 IsPrivateReference ( referenceRecord )

The abstract operation IsPrivateReference takes argument referenceRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. referenceRecord.[[ReferencedName]]Private Name なら、true を返す。
  2. false を返す。

6.2.5.5 GetValue ( referenceRecord )

The abstract operation GetValue takes argument referenceRecord (a Reference Record or an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. referenceRecordReference Record でないなら、referenceRecord を返す。
  2. IsUnresolvableReference(referenceRecord) が true なら、ReferenceError 例外を投げる。
  3. IsPropertyReference(referenceRecord) が true なら、
    1. baseObj を ? ToObject(referenceRecord.[[Base]]) とする。
    2. IsPrivateReference(referenceRecord) が true なら、
      1. PrivateGet(baseObj, referenceRecord.[[ReferencedName]]) を返す。
    3. referenceRecord.[[ReferencedName]]property key でないなら、
      1. referenceRecord.[[ReferencedName]] を ? ToPropertyKey(referenceRecord.[[ReferencedName]]) に設定する。
    4. baseObj.[[Get]](referenceRecord.[[ReferencedName]], GetThisValue(referenceRecord)) を返す。
  4. basereferenceRecord.[[Base]] とする。
  5. Assert: baseEnvironment Record である。
  6. base.GetBindingValue(referenceRecord.[[ReferencedName]], referenceRecord.[[Strict]]) を返す(9.1 を参照)。
Note

手順 3.a で生成されうるオブジェクトは、上記抽象操作および ordinary object[[Get]] 内部メソッドの外側からはアクセスできない。実装は、そのオブジェクトを実際には生成しないことを選んでもよい。

6.2.5.6 PutValue ( referenceRecord, value )

The abstract operation PutValue takes arguments referenceRecord (a Reference Record or an ECMAScript language value) and value (an ECMAScript language value) and returns either a normal completion containing unused or an abrupt completion. It performs the following steps when called:

  1. referenceRecordReference Record でないなら、ReferenceError 例外を投げる。
  2. IsUnresolvableReference(referenceRecord) が true なら、
    1. referenceRecord.[[Strict]]true なら、ReferenceError 例外を投げる。
    2. globalObjGetGlobalObject() とする。
    3. Set(globalObj, referenceRecord.[[ReferencedName]], value, false) を実行する。
    4. unused を返す。
  3. IsPropertyReference(referenceRecord) が true なら、
    1. baseObj を ? ToObject(referenceRecord.[[Base]]) とする。
    2. IsPrivateReference(referenceRecord) が true なら、
      1. PrivateSet(baseObj, referenceRecord.[[ReferencedName]], value) を返す。
    3. referenceRecord.[[ReferencedName]]property key でないなら、
      1. referenceRecord.[[ReferencedName]] を ? ToPropertyKey(referenceRecord.[[ReferencedName]]) に設定する。
    4. succeeded を ? baseObj.[[Set]](referenceRecord.[[ReferencedName]], value, GetThisValue(referenceRecord)) とする。
    5. succeededfalse かつ referenceRecord.[[Strict]]true なら、TypeError 例外を投げる。
    6. unused を返す。
  4. basereferenceRecord.[[Base]] とする。
  5. Assert: baseEnvironment Record である。
  6. base.SetMutableBinding(referenceRecord.[[ReferencedName]], value, referenceRecord.[[Strict]]) を返す(9.1 を参照)。
Note

手順 3.a で生成されうるオブジェクトは、上記抽象操作および ordinary object[[Set]] 内部メソッドの外側からはアクセスできない。実装は、そのオブジェクトを実際には生成しないことを選んでもよい。

6.2.5.7 GetThisValue ( referenceRecord )

The abstract operation GetThisValue takes argument referenceRecord (a Reference Record) and returns an ECMAScript language value. It performs the following steps when called:

  1. Assert: IsPropertyReference(referenceRecord) is true.
  2. IsSuperReference(referenceRecord) が true なら、referenceRecord.[[ThisValue]] を返す。
  3. referenceRecord.[[Base]] を返す。

6.2.5.8 InitializeReferencedBinding ( referenceRecord, value )

The abstract operation InitializeReferencedBinding takes arguments referenceRecord (a Reference Record) and value (an ECMAScript language value) and returns either a normal completion containing unused or an abrupt completion. It performs the following steps when called:

  1. Assert: IsUnresolvableReference(referenceRecord) is false.
  2. basereferenceRecord.[[Base]] とする。
  3. Assert: baseEnvironment Record である。
  4. base.InitializeBinding(referenceRecord.[[ReferencedName]], value) を返す。

6.2.5.9 MakePrivateReference ( baseValue, privateIdentifier )

The abstract operation MakePrivateReference takes arguments baseValue (an ECMAScript language value) and privateIdentifier (a String) and returns a Reference Record. It performs the following steps when called:

  1. privateEnv を、実行中の execution context の PrivateEnvironment とする。
  2. Assert: privateEnvnull ではない。
  3. privateNameResolvePrivateIdentifier(privateEnv, privateIdentifier) とする。
  4. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: privateName, [[Strict]]: true, [[ThisValue]]: empty } を返す。

6.2.6 Property Descriptor 仕様型

Property Descriptor 型は、Object のプロパティ属性の操作および具現化を説明するために使用される。Property Descriptor は 0 個以上のフィールドを持つ Record であり、各フィールド名は属性名であり、その値は 6.1.7.1 に規定された対応する属性値である。この仕様の中で、Property Descriptor record のリテラル記述にタグ付けするために使用される schema 名は “PropertyDescriptor” である。

Property Descriptor 値は、特定のフィールドの存在または使用に基づいて、data Property Descriptor と accessor Property Descriptor にさらに分類できる。data Property Descriptor とは、[[Value]] または [[Writable]] のいずれかのフィールドを含むものである。accessor Property Descriptor とは、[[Get]] または [[Set]] のいずれかのフィールドを含むものである。任意の Property Descriptor は [[Enumerable]] および [[Configurable]] という名前のフィールドを持っていてよい。Property Descriptor 値は、data Property Descriptor と accessor Property Descriptor の両方であることはできないが、そのいずれでもないことはありうる(この場合、それは generic Property Descriptor である)。fully populated Property Descriptor とは、accessor Property Descriptor または data Property Descriptor のいずれかであり、かつ Table 3 に定義された対応するすべてのフィールドを持つものである。

以下の抽象操作は、この仕様において Property Descriptor 値を操作するために使用される。

6.2.6.1 IsAccessorDescriptor ( desc )

The abstract operation IsAccessorDescriptor takes argument desc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:

  1. desc[[Get]] フィールドを持つなら、true を返す。
  2. desc[[Set]] フィールドを持つなら、true を返す。
  3. false を返す。

6.2.6.2 IsDataDescriptor ( desc )

The abstract operation IsDataDescriptor takes argument desc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:

  1. desc[[Value]] フィールドを持つなら、true を返す。
  2. desc[[Writable]] フィールドを持つなら、true を返す。
  3. false を返す。

6.2.6.3 IsGenericDescriptor ( desc )

The abstract operation IsGenericDescriptor takes argument desc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:

  1. IsAccessorDescriptor(desc) が true なら、false を返す。
  2. IsDataDescriptor(desc) が true なら、false を返す。
  3. true を返す。

6.2.6.4 FromPropertyDescriptor ( desc )

The abstract operation FromPropertyDescriptor takes argument desc (a Property Descriptor or undefined) and returns an Object or undefined. It performs the following steps when called:

  1. descundefined なら、undefined を返す。
  2. objOrdinaryObjectCreate(%Object.prototype%) とする。
  3. Assert: obj は own property を持たない extensible な ordinary object である。
  4. desc[[Value]] フィールドを持つ場合、
    1. CreateDataPropertyOrThrow(obj, "value", desc.[[Value]]) を実行する。
  5. desc[[Writable]] フィールドを持つ場合、
    1. CreateDataPropertyOrThrow(obj, "writable", desc.[[Writable]]) を実行する。
  6. desc[[Get]] フィールドを持つ場合、
    1. CreateDataPropertyOrThrow(obj, "get", desc.[[Get]]) を実行する。
  7. desc[[Set]] フィールドを持つ場合、
    1. CreateDataPropertyOrThrow(obj, "set", desc.[[Set]]) を実行する。
  8. desc[[Enumerable]] フィールドを持つ場合、
    1. CreateDataPropertyOrThrow(obj, "enumerable", desc.[[Enumerable]]) を実行する。
  9. desc[[Configurable]] フィールドを持つ場合、
    1. CreateDataPropertyOrThrow(obj, "configurable", desc.[[Configurable]]) を実行する。
  10. obj を返す。

6.2.6.5 ToPropertyDescriptor ( obj )

The abstract operation ToPropertyDescriptor takes argument obj (an ECMAScript language value) and returns either a normal completion containing a Property Descriptor or a throw completion. It performs the following steps when called:

  1. obj が Object でないなら、TypeError 例外を投げる。
  2. 最初はフィールドを持たない新しい Property Descriptor として desc を作る。
  3. hasEnumerable を ? HasProperty(obj, "enumerable") とする。
  4. hasEnumerabletrue の場合、
    1. enumerableToBoolean(? Get(obj, "enumerable")) とする。
    2. desc.[[Enumerable]]enumerable に設定する。
  5. hasConfigurable を ? HasProperty(obj, "configurable") とする。
  6. hasConfigurabletrue の場合、
    1. configurableToBoolean(? Get(obj, "configurable")) とする。
    2. desc.[[Configurable]]configurable に設定する。
  7. hasValue を ? HasProperty(obj, "value") とする。
  8. hasValuetrue の場合、
    1. value を ? Get(obj, "value") とする。
    2. desc.[[Value]]value に設定する。
  9. hasWritable を ? HasProperty(obj, "writable") とする。
  10. hasWritabletrue の場合、
    1. writableToBoolean(? Get(obj, "writable")) とする。
    2. desc.[[Writable]]writable に設定する。
  11. hasGet を ? HasProperty(obj, "get") とする。
  12. hasGettrue の場合、
    1. getter を ? Get(obj, "get") とする。
    2. IsCallable(getter) が false かつ getterundefined でないなら、TypeError 例外を投げる。
    3. desc.[[Get]]getter に設定する。
  13. hasSet を ? HasProperty(obj, "set") とする。
  14. hasSettrue の場合、
    1. setter を ? Get(obj, "set") とする。
    2. IsCallable(setter) が false かつ setterundefined でないなら、TypeError 例外を投げる。
    3. desc.[[Set]]setter に設定する。
  15. desc[[Get]] フィールドまたは [[Set]] フィールドを持つ場合、
    1. desc[[Value]] フィールドまたは [[Writable]] フィールドを持つなら、TypeError 例外を投げる。
  16. desc を返す。

6.2.6.6 CompletePropertyDescriptor ( desc )

The abstract operation CompletePropertyDescriptor takes argument desc (a Property Descriptor) and returns unused. It performs the following steps when called:

  1. likeRecord { [[Value]]: undefined, [[Writable]]: false, [[Get]]: undefined, [[Set]]: undefined, [[Enumerable]]: false, [[Configurable]]: false } とする。
  2. IsGenericDescriptor(desc) が true または IsDataDescriptor(desc) が true の場合、
    1. desc[[Value]] フィールドを持たないなら、desc.[[Value]]like.[[Value]] に設定する。
    2. desc[[Writable]] フィールドを持たないなら、desc.[[Writable]]like.[[Writable]] に設定する。
  3. Else,
    1. desc[[Get]] フィールドを持たないなら、desc.[[Get]]like.[[Get]] に設定する。
    2. desc[[Set]] フィールドを持たないなら、desc.[[Set]]like.[[Set]] に設定する。
  4. desc[[Enumerable]] フィールドを持たないなら、desc.[[Enumerable]]like.[[Enumerable]] に設定する。
  5. desc[[Configurable]] フィールドを持たないなら、desc.[[Configurable]]like.[[Configurable]] に設定する。
  6. unused を返す。

6.2.7 Environment Record 仕様型

Environment Record 型は、ネストした関数やブロックにおける名前解決の挙動を説明するために使用される。この型とその操作は 9.1 で定義される。

6.2.8 Abstract Closure 仕様型

Abstract Closure 仕様型は、値の集合とともにアルゴリズム手順を参照するために使用される。Abstract Closure はメタ値であり、closure(arg1, arg2) のような関数適用形式を用いて呼び出される。抽象操作と同様に、呼出しはその Abstract Closure によって記述されたアルゴリズム手順を実行する。

Abstract Closure を作成するアルゴリズム手順では、値は “capture” という動詞に続く別名のリストを用いて捕捉される。Abstract Closure が作成されるとき、その時点で各別名に関連付けられている値を捕捉する。Abstract Closure が呼び出されたときに実行されるアルゴリズムを規定する手順では、各捕捉値は、その値を捕捉するために使用された別名によって参照される。

Abstract Closure が Completion Record を返す場合、その Completion Recordnormal completion または throw completion のいずれかでなければならない。

Abstract Closure は、他のアルゴリズムの一部としてインラインで作成される。次の例に示す。

  1. addend を 41 とする。
  2. closure を、新しい Abstract Closure とする。この Closure はパラメータ (x) を持ち、addend を捕捉し、呼び出されたときに次の手順を実行する:
    1. x + addend を返す。
  3. valclosure(1) とする。
  4. Assert: val は 42 である。

6.2.9 Data Block

Data Block 仕様型は、バイト単位(8 ビット)の数値の、独立した可変の列を記述するために使用される。byte value とは、0 から 255 までの包含区間にある整数である。Data Block 値は、各バイトの初期値が 0 である固定個数のバイトで作成される。

この仕様内での記法上の便宜のため、配列風の構文を用いて Data Block 値の個々のバイトへアクセスできる。この記法は、Data Block 値を 0 始まりの integer-indexed なバイト列として表す。たとえば、db が 5 バイトの Data Block 値である場合、db[2] を用いてその 3rd バイトへアクセスできる。

複数の agent から同時に参照可能なメモリ上に存在する data block は、Shared Data Block として指定される。Shared Data Block は、(Shared Data Block 値の等価性判定の目的において)address-free な identity を持つ。すなわち、その identity は任意のプロセスにおいてその block がマップされる仮想アドレスには結び付かず、その block が表すメモリ位置の集合に結び付く。2 つの data block が等しいのは、それらが含む位置集合が等しい場合に限られる。そうでない場合、それらは等しくなく、それらが含む位置集合の共通部分は空である。さらに、Shared Data Block は Data Block と区別できる。

Shared Data Block の意味論は、メモリモデルによって Shared Data Block event を用いて定義される。以下の抽象操作は Shared Data Block event を導入し、評価意味論とメモリモデルの event 意味論との間のインターフェースとして機能する。これらの event は候補 execution を形成し、それに対してメモリモデルがフィルタとして作用する。完全な意味論についてはメモリモデルを参照されたい。

Shared Data Block event は、メモリモデルで定義される Record によってモデル化される。

以下の抽象操作は、この仕様において Data Block 値を操作するために使用される。

6.2.9.1 CreateByteDataBlock ( size )

The abstract operation CreateByteDataBlock takes argument size (a non-negative integer) and returns either a normal completion containing a Data Block or a throw completion. It performs the following steps when called:

  1. size > 253 - 1 なら、RangeError 例外を投げる。
  2. size バイトから成る新しい Data Blockdb を作る。そのような Data Block を作成できない場合、RangeError 例外を投げる。
  3. db のすべてのバイトを 0 に設定する。
  4. db を返す。

6.2.9.2 CreateSharedByteDataBlock ( size )

The abstract operation CreateSharedByteDataBlock takes argument size (a non-negative integer) and returns either a normal completion containing a Shared Data Block or a throw completion. It performs the following steps when called:

  1. size バイトから成る新しい Shared Data Blockdb を作る。そのような Shared Data Block を作成できない場合、RangeError 例外を投げる。
  2. agentRecord を、周囲の agentAgent Record とする。
  3. executionagentRecord.[[CandidateExecution]] とする。
  4. eventsRecord を、execution.[[EventsRecords]] のうち [[AgentSignifier]]AgentSignifier() である Agent Events Record とする。
  5. zero を « 0 » とする。
  6. db の各添字 i について、次を行う
    1. WriteSharedMemory { [[Order]]: init, [[NoTear]]: true, [[Block]]: db, [[ByteIndex]]: i, [[ElementSize]]: 1, [[Payload]]: zero } を eventsRecord.[[EventList]] に追加する。
  7. db を返す。

6.2.9.3 CopyDataBlockBytes ( toBlock, toIndex, fromBlock, fromIndex, count )

The abstract operation CopyDataBlockBytes takes arguments toBlock (a Data Block or a Shared Data Block), toIndex (a non-negative integer), fromBlock (a Data Block or a Shared Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns unused. It performs the following steps when called:

  1. Assert: fromBlocktoBlock は異なる値である。
  2. fromSizefromBlock 内のバイト数とする。
  3. Assert: fromIndex + countfromSize
  4. toSizetoBlock 内のバイト数とする。
  5. Assert: toIndex + counttoSize
  6. count > 0 の間、繰り返す
    1. fromBlockShared Data Block の場合、
      1. agentRecord を、周囲の agentAgent Record とする。
      2. executionagentRecord.[[CandidateExecution]] とする。
      3. eventsRecord を、execution.[[EventsRecords]] のうち [[AgentSignifier]]AgentSignifier() である Agent Events Record とする。
      4. bytes を、唯一の要素として非決定的に選ばれた byte value を持つ List とする。
      5. NOTE: 実装において、bytes は基盤ハードウェア上の非アトミック read 命令の結果である。非決定性は、弱い一貫性を持つハードウェアの観測可能な挙動を記述するための、メモリモデルによる意味論的規定である。
      6. readEventReadSharedMemory { [[Order]]: unordered, [[NoTear]]: true, [[Block]]: fromBlock, [[ByteIndex]]: fromIndex, [[ElementSize]]: 1 } とする。
      7. readEventeventsRecord.[[EventList]] に追加する。
      8. Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: bytes } を execution.[[ChosenValues]] に追加する。
      9. toBlockShared Data Block の場合、
        1. WriteSharedMemory { [[Order]]: unordered, [[NoTear]]: true, [[Block]]: toBlock, [[ByteIndex]]: toIndex, [[ElementSize]]: 1, [[Payload]]: bytes } を eventsRecord.[[EventList]] に追加する。
      10. Else,
        1. toBlock[toIndex] を bytes[0] に設定する。
    2. Else,
      1. Assert: toBlockShared Data Block ではない。
      2. toBlock[toIndex] を fromBlock[fromIndex] に設定する。
    3. toIndextoIndex + 1 に設定する。
    4. fromIndexfromIndex + 1 に設定する。
    5. countcount - 1 に設定する。
  7. unused を返す。

6.2.10 PrivateElement 仕様型

PrivateElement 型は、private class field、method、および accessor の仕様において使用される Record である。Property Descriptor は private element には使用されないが、private field は non-configurable で non-enumerable、かつ writable な data property に類似して振る舞い、private method は non-configurable で non-enumerable、かつ non-writable な data property に類似して振る舞い、private accessor は non-configurable で non-enumerable な accessor property に類似して振る舞う。

PrivateElement 型の値は、Table 9 に定義されるフィールドを持つ Record 値である。そのような値は PrivateElements と呼ばれる。

Table 9: PrivateElement Fields
フィールド名 そのフィールドが存在する [[Kind]] フィールドの値 意味
[[Key]] All a Private Name field、method、または accessor の名前。
[[Kind]] All field, method, or accessor 要素の種類。
[[Value]] field and method an ECMAScript language value field の値。
[[Get]] accessor a function object or undefined private accessor の getter。
[[Set]] accessor a function object or undefined private accessor の setter。

6.2.11 ClassFieldDefinition Record 仕様型

ClassFieldDefinition 型は、class field の仕様において使用される Record である。

ClassFieldDefinition 型の値は、Table 10 に定義されるフィールドを持つ Record 値である。そのような値は ClassFieldDefinition Records と呼ばれる。

Table 10: ClassFieldDefinition Record Fields
フィールド名 意味
[[Name]] a Private Name, a String, or a Symbol field の名前。
[[Initializer]] an ECMAScript function object or empty 存在する場合、その field の initializer。

6.2.12 Private Name

Private Name 仕様型は、private class element(field、method、または accessor)のキーを表す、グローバルに一意な値(たとえ他の点で区別不能であっても、他のあらゆる Private Name と異なる値)を記述するために使用される。各 Private Name は、不変の [[Description]] 内部スロットを持ち、その値は String である。Private Name は、任意の ECMAScript object に対して PrivateFieldAdd または PrivateMethodOrAccessorAdd によって取り付けることができ、その後 PrivateGet および PrivateSet によって読み書きできる。

6.2.13 ClassStaticBlockDefinition Record 仕様型

ClassStaticBlockDefinition Record は、class static initialization block の実行可能コードをカプセル化するために使用される Record 値である。

ClassStaticBlockDefinition Record は、Table 11 に列挙されるフィールドを持つ。

Table 11: ClassStaticBlockDefinition Record Fields
フィールド名 意味
[[BodyFunction]] an ECMAScript function object class の static 初期化中に呼び出される function object