?
u
m
/
p
1-9
0
`
本规范中的算法操作的值都具有相关的类型。可能的值类型正是本条款中定义的类型。类型进一步分为
ECMAScript 语言类型对应于 ECMAScript 编程人员可直接通过 ECMAScript 语言操作的值。ECMAScript 语言类型包括 Undefined、Null、Boolean、String、Symbol、Number、BigInt 和 Object。ECMAScript 语言值是指具有 ECMAScript 语言类型特征的值。
Undefined 类型只有一个值,称为
Null 类型只有一个值,称为
Boolean 类型表示一个逻辑实体,具有两个值,分别为
String 类型是所有有序的零个或多个 16 位无符号整数值(“元素”)序列的集合,最大长度为 253 - 1 个元素。String 类型通常用于表示 ECMAScript 程序中的文本数据,此时每个元素都被视为一个 UTF-16 码元值。每个元素被认为在序列中占据一个位置,这些位置用非负
未解释字符串内容的 ECMAScript 操作不施加进一步语义。解释字符串值的操作则将每个元素视为单个 UTF-16 码元。然而,ECMAScript 不限制这些码元的值或相互关系,因此进一步将字符串内容解释为 UTF-16 编码的 Unicode 码点序列时,必须考虑不规范的子序列。此类操作会对数值在
可使用 String.prototype.normalize
(见 String.prototype.localeCompare
(见
该设计的理由是使字符串实现尽量简单且高效。如果 ECMAScript 源文本为标准化形式 C,则字符串字面量也一定是标准化的,只要其中不包含 Unicode 转义序列。
在本规范中,“the string-concatenation of A, B, ...”(每个参数为字符串值、码元或码元序列)表示顺序连接每个参数的码元后得到的字符串值。
“the substring of S from inclusiveStart to exclusiveEnd”(S 为字符串值或码元序列,inclusiveStart 和 exclusiveEnd 为整数)表示从索引 inclusiveStart 到紧邻索引 exclusiveEnd 之前的顺序码元组成的字符串值(当 inclusiveStart = exclusiveEnd 时为空字符串)。若省略 "to" 后缀,则 exclusiveEnd 取 S 的长度。
“the ASCII word characters”表示如下字符串值,仅包含 Unicode 基本拉丁区的所有字母和数字以及 U+005F(下划线):
出于历史原因,在多种算法中具有特殊意义。
The abstract operation StringIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative
如果 searchValue 是空字符串且 fromIndex ≤ string 的长度,则返回 fromIndex。空字符串在字符串的每个位置都可找到,包括最后一个码元之后。
如果 fromIndex + searchValue 的长度大于 string 的长度,则本算法总是返回
The abstract operation StringLastIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative
如果 searchValue 是空字符串,则算法返回 fromIndex。空字符串在字符串的每个位置都可找到,包括最后一个码元之后。
Symbol 类型是所有可用作对象
每个 Symbol 都是唯一且不可变的。
每个 Symbol 都有一个不可变的 [[Description]] 内部槽,其值为字符串或
知名 Symbol 是规范算法明确引用的内建 Symbol 值。它们通常用作
在本规范中,知名 Symbol 使用标准的
规范名称 | [[Description]] | 值及用途 |
---|---|---|
%Symbol.asyncIterator% |
|
返回对象默认异步迭代器的方法。由 for -await -of 语句语义调用。
|
%Symbol.hasInstance% |
|
判断instanceof 运算符语义调用。
|
%Symbol.isConcatSpreadable% |
|
一个布尔属性,若为 true 则 Array.prototype.concat |
%Symbol.iterator% |
|
返回对象默认迭代器的方法。由 for-of 语句语义调用。 |
%Symbol.match% |
|
正则表达式方法,用于匹配字符串。由 String.prototype.match |
%Symbol.matchAll% |
|
正则表达式方法,返回迭代器,用于遍历字符串的所有匹配项。由 String.prototype.matchAll |
%Symbol.replace% |
|
正则表达式方法,用于替换字符串中的匹配子串。由 String.prototype.replace |
%Symbol.search% |
|
正则表达式方法,返回匹配字符串的索引。由 String.prototype.search |
%Symbol.species% |
|
一个函数属性,是用于创建派生对象的 |
%Symbol.split% |
|
正则表达式方法,用于在匹配索引处分割字符串。由 String.prototype.split |
%Symbol.toPrimitive% |
|
将对象转换为对应原始值的方法。由 ToPrimitive |
%Symbol.toStringTag% |
|
用于创建对象默认字符串描述的字符串属性。通过内建方法 Object.prototype.toString |
%Symbol.unscopables% |
|
一个对象属性,其自身和继承的with 环境绑定中被排除的 |
ECMAScript 有两种内建数值类型:Number 和 BigInt。以下
由于数值类型通常无法在不丢失精度或截断的情况下进行转换,ECMAScript 语言不提供这些类型之间的隐式转换。程序员必须显式调用 Number
和 BigInt
函数来在调用需要另一种类型的函数时进行类型转换。
ECMAScript 的第一版及后续版本为某些运算符提供了可能丢失精度或截断的隐式数值转换。为了兼容旧代码,这些传统的隐式转换仍然保留,但对于 BigInt 不再提供,以最大程度减少程序员出错的机会,并为将来版本支持更广泛的 值类型 留下空间。
Number 类型一共有 18,437,736,874,454,810,627 个值(即 NaN
得到。)在某些实现中,外部代码可能能区分不同的 NaN,但这种行为由实现定义;对于 ECMAScript 代码,所有
还有两个特殊值,称为 +Infinity
(或简写为 Infinity
)和 -Infinity
得到。)
其余 18,437,736,874,454,810,624 个值(即
注意,存在 +0
(或简写为 0
)和 -0
得到。)
18,437,736,874,454,810,622 个
其中 18,428,729,675,200,069,632 个(即
其中 s 为 1 或 -1,m 是
剩下的 9,007,199,254,740,990 个值(即
其中 s 为 1 或 -1,m 是 (0, 252)
注意,所有绝对值不超过 253 的正负整数都能用 Number 类型表示。整数 0 在 Number 类型中有两种表示:
在本规范中,“x 的 Number 值”表示 x 是某个精确的数学实数(甚至可能是无理数如 π),其 Number 值按如下方式选取:取所有
+∞ 的 Number 值为
某些 ECMAScript 运算符只处理范围特定的整数,比如 [-231, 231 - 1] 或 [0, 216 - 1]。这些运算符接受任意 Number 类型值,但会先将其转换为预期范围的整数。具体转换见
The abstract operation Number::unaryMinus takes argument x (一个 Number) and returns 一个 Number. It performs the following steps when called:
The abstract operation Number::bitwiseNOT takes argument x (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
The abstract operation Number::exponentiate takes arguments base (一个 Number) and exponent (一个 Number) and returns 一个 Number. It performs the following steps when called:
当 base 为 **
exponent 的结果与
The abstract operation Number::multiply takes arguments x (一个 Number) and y (一个 Number) and returns 一个 Number. It performs the following steps when called:
The abstract operation Number::divide takes arguments x (一个 Number) and y (一个 Number) and returns 一个 Number. It performs the following steps when called:
The abstract operation Number::remainder takes arguments n (一个 Number) and d (一个 Number) and returns 一个 Number. It performs the following steps when called:
C 和 C++ 的余数运算符只接受整数操作数;而 ECMAScript 也接受浮点数操作数。
%
的结果与 %
运算针对浮点数时的行为类似于 Java The abstract operation Number::add takes arguments x (一个 Number) and y (一个 Number) and returns 一个 Number. It performs the following steps when called:
The abstract operation Number::subtract takes arguments x (一个 Number) and y (一个 Number) and returns 一个 Number. It performs the following steps when called:
始终有 x - y
的结果与 x + (-y)
相同。
The abstract operation Number::leftShift takes arguments x (一个 Number) and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
The abstract operation Number::signedRightShift takes arguments x (一个 Number) and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
The abstract operation Number::unsignedRightShift takes arguments x (一个 Number) and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
The abstract operation Number::lessThan takes arguments x (一个 Number) and y (一个 Number) and returns Boolean 或
The abstract operation Number::equal takes arguments x (一个 Number) and y (一个 Number) and returns Boolean. It performs the following steps when called:
The abstract operation Number::sameValue takes arguments x (一个 Number) and y (一个 Number) and returns Boolean. It performs the following steps when called:
The abstract operation Number::sameValueZero takes arguments x (一个 Number) and y (一个 Number) and returns Boolean. It performs the following steps when called:
The abstract operation NumberBitwiseOp takes arguments op (&
, ^
, 或 |
), x (一个 Number), and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
The abstract operation Number::bitwiseAND takes arguments x (一个 Number) and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
&
, x, y)。The abstract operation Number::bitwiseXOR takes arguments x (一个 Number) and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
^
, x, y)。The abstract operation Number::bitwiseOR takes arguments x (一个 Number) and y (一个 Number) and returns 一个整数 Number. It performs the following steps when called:
|
, x, y)。The abstract operation Number::toString takes arguments x (一个 Number) and radix (2 到 36 之间的整数) and returns 一个字符串. It performs the following steps when called:
1.2e+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). 1990 年 11 月 30 日。参见
https://ampl.com/_archive/first-website/REFS/rounding.pdf。相关代码见
http://netlib.sandia.gov/fp/dtoa.c 以及
http://netlib.sandia.gov/fp/g_fmt.c,也可在多个 netlib
镜像站点找到。
BigInt 类型表示整数值。该值可以为任意大小,不受特定位宽限制。通常,除非另有说明,相关操作都设计为返回精确的数学答案。对于二元运算,BigInt 被视为二进制补码字符串,负数则被视为左边有无限个被置位的位。
The abstract operation BigInt::unaryMinus takes argument x (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::bitwiseNOT takes argument x (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::exponentiate takes arguments base (一个 BigInt) and exponent (一个 BigInt) and returns 正常返回一个 BigInt 或抛出异常. It performs the following steps when called:
The abstract operation BigInt::multiply takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::divide takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 正常返回一个 BigInt 或抛出异常. It performs the following steps when called:
The abstract operation BigInt::remainder takes arguments n (一个 BigInt) and d (一个 BigInt) and returns 正常返回一个 BigInt 或抛出异常. It performs the following steps when called:
The abstract operation BigInt::add takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::subtract takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::leftShift takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::signedRightShift takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::unsignedRightShift takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 抛出异常. It performs the following steps when called:
The abstract operation BigInt::lessThan takes arguments x (一个 BigInt) and y (一个 BigInt) and returns Boolean. It performs the following steps when called:
The abstract operation BigInt::equal takes arguments x (一个 BigInt) and y (一个 BigInt) and returns Boolean. It performs the following steps when called:
The abstract operation BinaryAnd takes arguments x (0 或 1) and y (0 或 1) and returns 0 或 1. It performs the following steps when called:
The abstract operation BinaryOr takes arguments x (0 或 1) and y (0 或 1) and returns 0 或 1. It performs the following steps when called:
The abstract operation BinaryXor takes arguments x (0 或 1) and y (0 或 1) and returns 0 或 1. It performs the following steps when called:
The abstract operation BigIntBitwiseOp takes arguments op (&
, ^
, 或 |
), x (一个 BigInt), and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
The abstract operation BigInt::bitwiseAND takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
&
, x, y)。The abstract operation BigInt::bitwiseXOR takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
^
, x, y)。The abstract operation BigInt::bitwiseOR takes arguments x (一个 BigInt) and y (一个 BigInt) and returns 一个 BigInt. It performs the following steps when called:
|
, x, y)。The abstract operation BigInt::toString takes arguments x (一个 BigInt) and radix (2 到 36 之间的整数) and returns 一个字符串. It performs the following steps when called:
每个 Object 类型的实例,也简称为“对象”,表示一组属性的集合。每个属性要么是数据属性,要么是访问器属性:
对象的属性通过
整数索引是
所有对象在逻辑上都是属性的集合,但对象有多种形式,不同形式在访问和操作属性时语义有所区别。参见
此外,某些对象可调用,被称为函数或
本规范使用属性(attributes)来定义和解释对象属性的状态,详见
特性名称 | 适用属性类型 | 值域 | 默认值 | 描述 |
---|---|---|---|---|
[[Value]] |
|
一个 |
|
通过 get 访问属性时获得的值。 |
[[Writable]] |
|
布尔值 |
|
如果为 |
[[Get]] |
|
对象或 |
|
如果值是对象,则必须为 |
[[Set]] |
|
对象或 |
|
如果值是对象,则必须为 |
[[Enumerable]] |
|
布尔值 |
|
如果为 |
[[Configurable]] |
|
布尔值 |
|
如果为 |
ECMAScript 中对象的实际语义通过称为内部方法的算法来定义。每个 ECMAScript 引擎中的对象都关联一组内部方法,定义其运行时行为。这些内部方法不是 ECMAScript 语言的一部分,仅供规范说明之用。但 ECMAScript 的每个对象都必须符合其关联的内部方法的行为,具体实现方式由实现决定。
内部方法名称是多态的。意味着不同对象值在调用相同内部方法名时可以执行不同的算法。被调用的实际对象是该方法的“目标”。如果在运行时算法实现尝试使用一个对象未支持的内部方法,则抛出
内部槽对应于与对象、Symbol 或私有名称关联的内部状态,被 ECMAScript 规范的各种算法使用。内部槽不是对象属性,也不会被继承。根据具体内部槽的规定,这些状态可以是任意 ECMAScript 类型值或特定 ECMAScript 规范类型值。除非另有说明,内部槽在创建对象、Symbol 或私有名称时分配,不能动态添加。除非另有说明,内部槽的初始值是
所有对象都有名为 [[PrivateElements]] 的内部槽,是一个
规范中用双中括号 [[ ]] 标识内部方法和内部槽。
普通对象是满足以下条件的对象:
特殊对象是不满足
本规范通过对象的内部方法区分不同类型的
除了参数之外,内部方法始终能访问作为方法调用目标的对象。
内部方法隐式返回一个
内部方法 | 签名 | 描述 |
---|---|---|
[[GetPrototypeOf]] | ( ) → Object | Null |
获取为此对象提供继承属性的对象。 |
[[SetPrototypeOf]] | (Object | Null) → Boolean |
将此对象与另一个提供继承属性的对象关联。传递 |
[[IsExtensible]] | ( ) → Boolean | 判断是否允许向此对象添加新属性。 |
[[PreventExtensions]] | ( ) → Boolean |
控制是否可向对象添加新属性。返回 |
[[GetOwnProperty]] |
(propertyKey) → Undefined | |
返回此对象自身属性中键为 propertyKey 的属性描述符,若无则返回 |
[[DefineOwnProperty]] | (propertyKey, PropertyDescriptor) → Boolean |
创建或更改自身属性(键为 propertyKey),使其状态与 PropertyDescriptor 描述一致。成功时返回 |
[[HasProperty]] | (propertyKey) → Boolean | 返回布尔值,表示此对象是否已有自身或继承属性,其键为 propertyKey。 |
[[Get]] | (propertyKey, Receiver) → any |
获取此对象中键为 propertyKey 的属性值。若需执行 ECMAScript 代码以获取属性值,则 Receiver 作为 |
[[Set]] | (propertyKey, value, Receiver) → Boolean |
将键为 propertyKey 的属性值设为 value。若需执行 ECMAScript 代码以设置属性值,则 Receiver 作为 |
[[Delete]] | (propertyKey) → Boolean |
删除自身 |
[[OwnPropertyKeys]] |
( ) → |
返回对象所有自身 |
ECMAScript 引擎中的对象的内部方法必须符合下列不变量。普通 ECMAScript 对象以及本规范中的所有标准
任何实现提供的
实现不得以任何方式绕过这些不变量,比如提供不强制不变量的方法接口来实现基本内部方法。
任何内部方法返回的值必须是一个
内部方法不得返回 continue、break 或 return 类型的
由第三条不变量可知,如果某属性被描述为
知名内置对象是本规范的算法显式引用的内置对象,通常具有特定于“域”(
在本规范中,%name% 表示当前域关联的对应名称的内置对象。%name.a.b% 表示在执行任何 ECMAScript 代码之前,访问内置对象 %name% 的属性 "a",再访问该属性的 "b" 属性。当前域和其内置对象的确定见
内置名称 | 全局名称 | ECMAScript 语言关联 |
---|---|---|
|
AggregateError
|
AggregateError |
|
Array
|
Array |
|
ArrayBuffer
|
ArrayBuffer |
|
数组迭代器对象的原型(参见 |
|
|
Async-from-Sync 迭代器对象的原型(参见 |
|
|
async |
|
|
async 生成器 |
|
|
async 生成器对象的原型(参见 |
|
|
所有标准内置 async 迭代器对象的间接继承对象 | |
|
Atomics
|
Atomics 对象(参见 |
|
BigInt
|
BigInt |
|
BigInt64Array
|
BigInt64Array |
|
BigUint64Array
|
BigUint64Array |
|
Boolean
|
Boolean |
|
DataView
|
DataView |
|
Date
|
Date |
|
decodeURI
|
decodeURI 函数(参见 |
|
decodeURIComponent
|
decodeURIComponent 函数(参见 |
|
encodeURI
|
encodeURI 函数(参见 |
|
encodeURIComponent
|
encodeURIComponent 函数(参见 |
|
Error
|
Error |
|
eval
|
eval 函数(参见 |
|
EvalError
|
EvalError |
|
FinalizationRegistry
|
|
|
Float16Array
|
Float16Array |
|
Float32Array
|
Float32Array |
|
Float64Array
|
Float64Array |
|
For-In 迭代器对象的原型(参见 |
|
|
Function
|
Function |
|
生成器 |
|
|
生成器对象的原型(参见 |
|
|
Int8Array
|
Int8Array |
|
Int16Array
|
Int16Array |
|
Int32Array
|
Int32Array |
|
isFinite
|
isFinite 函数(参见 |
|
isNaN
|
isNaN 函数(参见 |
|
Iterator
|
Iterator |
|
|
|
|
JSON
|
JSON 对象(参见 |
|
Map
|
Map |
|
Map 迭代器对象的原型(参见 |
|
|
Math
|
Math 对象(参见 |
|
Number
|
Number |
|
Object
|
Object |
|
parseFloat
|
parseFloat 函数(参见 |
|
parseInt
|
parseInt 函数(参见 |
|
Promise
|
Promise |
|
Proxy
|
Proxy |
|
RangeError
|
RangeError |
|
ReferenceError
|
ReferenceError |
|
Reflect
|
Reflect 对象(参见 |
|
RegExp
|
RegExp |
|
正则表达式字符串迭代器对象的原型(参见 |
|
|
Set
|
Set |
|
Set 迭代器对象的原型(参见 |
|
|
SharedArrayBuffer
|
SharedArrayBuffer |
|
String
|
String |
|
字符串迭代器对象的原型(参见 |
|
|
Symbol
|
Symbol |
|
SyntaxError
|
SyntaxError |
|
一个 |
|
|
所有类型化数组 |
|
|
TypeError
|
TypeError |
|
Uint8Array
|
Uint8Array |
|
Uint8ClampedArray
|
Uint8ClampedArray |
|
Uint16Array
|
Uint16Array |
|
Uint32Array
|
Uint32Array |
|
URIError
|
URIError |
|
WeakMap
|
WeakMap |
|
WeakRef
|
|
|
WeakSet
|
WeakSet |
|
Iterator.from 返回的包装迭代器对象的原型(参见 |
更多条目见
规范类型对应于算法中用于描述 ECMAScript 语言结构和
枚举是规范内部使用的值,不能被 ECMAScript 代码直接观察。枚举用
List 类型用于解释参数列表(参见 new
表达式、函数调用以及需要简单有序值列表的其他算法中的求值。List 类型的值就是包含各个值的有序元素序列,序列长度可任意。List 的元素可用 0 起始的索引随机访问。为方便记号,可用类似数组的语法访问 List 元素。例如,arguments[2] 表示 List arguments 的第 3 个元素。
当算法遍历 List 元素但未指定顺序时,使用 List 元素的原有顺序。
在本规范中,为方便记号,可用字面量语法表达新的 List 值。例如,« 1, 2 » 定义了一个有两个元素的 List 值,每个元素初始化为特定值。空 List 可写作 « »。
在本规范中,“A、B... 的列表拼接”(每个参数都是可能为空的 List)表示一个新 List,其元素是各参数元素(按顺序)拼接而成。
对于字符串 List,“按字典序码位顺序排序”意指按较短字符串长度以内各码位的数值排序,如相等则短字符串排前,详见
Record 类型用于规范算法中的数据聚合。Record 类型值由一个或多个具名字段组成,每个字段的值为
在规范中,为方便记号,可用类似对象字面量的语法表达 Record 值。例如,{ [[Field1]]: 42, [[Field2]]:
在规范文本和算法中,可用点号表示法引用 Record 的某个字段。例如,若 R 为上文的 Record,则 R.[[Field2]] 表示“R 的 [[Field2]] 字段”。
常用字段组合的 Record 可以命名,并作为字面量前缀,以标识描述的聚合类型。例如:PropertyDescriptor { [[Value]]: 42, [[Writable]]:
Set 类型用于说明
Relation 类型用于说明集合上的约束。Relation 类型值是其值域上的有序对集合。例如,事件上的 Relation 是事件有序对的集合。若 Relation R,值域中的 a 和 b,则 a R b 表示有序对 (a, b) 属于 R。Relation 是满足某些条件的最小 Relation,即满足条件的
严格偏序是满足以下条件的 Relation 值 R。
对 R 的值域内所有 a、b、c:
上述两个条件分别称为反自反性和传递性。
严格全序是满足以下条件的 Relation 值 R。
对 R 的值域内所有 a、b、c:
上述三个条件分别称为全序性、反自反性和传递性。
Completion Record 规范类型用于解释运行时值和控制流的传播,如语句(break
、continue
、return
和 throw
)实现的非局部控制转移行为。
Completion Record 包含
字段名 | 值 | 含义 |
---|---|---|
[[Type]] |
|
发生的完成类型。 |
[[Value]] |
除 |
产生的值。 |
[[Target]] |
字符串或 |
用于定向控制转移的目标标签。 |
下列术语有时用于指代 Completion Record:
规范中定义的可调用对象只返回正常完成或 throw 完成。返回其他类型的 Completion Record 属于编辑错误。
The abstract operation NormalCompletion takes argument value (除
The abstract operation ThrowCompletion takes argument value (一个
The abstract operation ReturnCompletion takes argument value (一个
The abstract operation UpdateEmpty takes arguments completionRecord (一个
Reference Record 类型用于解释如 delete
、typeof
、赋值运算符、super
关键字等操作的行为。例如,赋值的左操作数应产生一个 Reference Record。
Reference Record 是已解析的名称或(可能尚未解析的)属性绑定;其字段定义见
字段名 | 值 | 含义 |
---|---|---|
[[Base]] | 一个 |
持有绑定的值或 |
[[ReferencedName]] | 一个 |
绑定的名称。若 [[Base]] 为 |
[[Strict]] | 布尔值 | 若 |
[[ThisValue]] | 一个 |
若非 super 关键字表达的属性绑定,称为 Super Reference Record,其 [[Base]] 不会是 |
本规范使用以下
The abstract operation IsPropertyReference takes argument V (一个
The abstract operation IsUnresolvableReference takes argument V (一个
The abstract operation IsSuperReference takes argument V (一个
The abstract operation IsPrivateReference takes argument V (一个
The abstract operation GetValue takes argument V (一个
The abstract operation PutValue takes arguments V (一个
The abstract operation GetThisValue takes argument V (一个
The abstract operation InitializeReferencedBinding takes arguments V (一个
The abstract operation MakePrivateReference takes arguments baseValue (一个
Property Descriptor 类型用于解释对象属性特性的操作及具现。Property Descriptor 是一个包含零个或多个字段的
Property Descriptor 值可根据某些字段的存在或用途进一步分为数据 Property Descriptor 和访问器 Property Descriptor。包含 [[Value]] 或 [[Writable]] 字段的为数据 Property Descriptor;包含 [[Get]] 或 [[Set]] 字段的为访问器 Property Descriptor。任意 Property Descriptor 都可包含 [[Enumerable]] 和 [[Configurable]] 字段。Property Descriptor 值不能同时为数据和访问器 Property Descriptor,但可以两者都不是(此时为通用 Property Descriptor)。完全填充的 Property Descriptor指为访问器 Property Descriptor 或数据 Property Descriptor 且已定义所有对应字段(见
本规范用以下
The abstract operation IsAccessorDescriptor takes argument Desc (一个
The abstract operation IsDataDescriptor takes argument Desc (一个
The abstract operation IsGenericDescriptor takes argument Desc (一个
The abstract operation FromPropertyDescriptor takes argument Desc (一个
The abstract operation ToPropertyDescriptor takes argument Obj (一个
The abstract operation CompletePropertyDescriptor takes argument Desc (一个
Abstract Closure 规范类型用于引用算法步骤及一组值。Abstract Closure 是元值,用函数调用风格如 closure(arg1, arg2) 调用。和
创建 Abstract Closure 的算法步骤,用 “capture” 和别名列表描述需捕获的值。创建时,按别名捕获当时关联的值。指定 Abstract Closure 被调用时的算法步骤时,每个捕获值都用其别名引用。
若 Abstract Closure 返回
Abstract Closure 通常作为其他算法的一部分内联创建,示例如下:
Data Block 规范类型用于描述一段独立且可变的字节(8 位)数值序列。字节值是 0 到 255 的整数。Data Block 值创建时拥有固定数量字节,每个初始值为 0。
在规范中,为方便记号,可用类似数组的语法访问 Data Block 的各字节。该记号将 Data Block 视为 0 起始
可被多个 agent 并发引用的驻留于内存的数据块称为 Shared Data Block。Shared Data Block 有一个用于相等性测试的无地址身份:它不是绑定到任何进程的虚拟地址,而是与所代表的内存位置集合绑定。只有包含的内存位置集合相等,两数据块才相等,否则不等且其集合交集为空。Shared Data Block 可与 Data Block 区分。
Shared Data Block 的语义由
Shared Data Block 事件由
本规范用以下
The abstract operation CreateByteDataBlock takes argument size (非负整数) and returns 返回包含
The abstract operation CreateSharedByteDataBlock takes argument size (非负整数) and returns 返回包含
The abstract operation CopyDataBlockBytes takes arguments toBlock (
PrivateElement 类型是用于规范私有类字段、方法和访问器的
PrivateElement 类型的值是包含
字段名 | 存在时 [[Kind]] 字段的值 | 值 | 含义 |
---|---|---|---|
[[Key]] | 所有 |
|
字段、方法或访问器的名称。 |
[[Kind]] | 所有 |
|
元素类型。 |
[[Value]] |
|
一个 |
字段的值。 |
[[Get]] |
|
|
私有访问器的 getter。 |
[[Set]] |
|
|
私有访问器的 setter。 |
ClassFieldDefinition 类型是用于规范类字段的
ClassFieldDefinition 类型的值是包含
字段名 | 值 | 含义 |
---|---|---|
[[Name]] |
|
字段的名称。 |
[[Initializer]] |
ECMAScript |
字段的初始化器(如有)。 |
Private Name 规范类型用于描述全局唯一值(即使与其他 Private Name 外观一致也不同),用于表示私有类元素(字段、方法或访问器)的键。每个 Private Name 有不可变的 [[Description]] 内部槽,为字符串。Private Name 可通过
ClassStaticBlockDefinition Record 是用于封装类静态初始化块可执行代码的
ClassStaticBlockDefinition Record 包含
字段名 | 值 | 含义 |
---|---|---|
[[BodyFunction]] |
一个 ECMAScript |
类静态初始化时要调用的 |