?um/p1-90`若
无论控制如何离开
eval 的调用都返回 1:
eval("1;;;;;")
eval("1;{}")
eval("1;var a;")
The abstract operation BlockDeclarationInstantiation takes arguments code (一个 Parse Node) and env (一个
当求值一个
调用时执行以下步骤:
let 与 const 声明的变量作用域为当前执行上下文的 LexicalEnvironment。变量在其包含的 let 声明中无
const 声明中。
var 声明的变量作用域为当前执行上下文的 VariableEnvironment。此类变量在其环境记录实例化时创建并初始化为
若
The syntax-directed operation
The syntax-directed operation
The syntax-directed operation
当 environment 传
It is defined piecewise over the following productions:
{ 开始以避免与 function 或 class 开头以避免与 async function 开头避免与 let [ 开头避免与以数组绑定模式为首绑定的 let
if 语句 (The if Statement)else] 以传统方式解决“悬挂的 else”问题:当关联的 if 有歧义时,将 else 归属最近的尚未匹配的 if。仅当实现了
The abstract operation LoopContinues takes arguments completion (一个
在
The syntax-directed operation
do-while 语句 (The do-while Statement)仅当实现了
The syntax-directed operation
while 语句 (The while Statement)仅当实现了
The syntax-directed operation
for 语句 (The for Statement)仅当实现
The syntax-directed operation
The abstract operation ForBodyEvaluation takes arguments test (
The abstract operation CreatePerIterationEnvironment takes argument perIterationBindings (字符串列表) and returns 返回
for-in、for-of 与 for-await-of 语句本节由附录
仅在实现
The syntax-directed operation
本节由附录
The syntax-directed operation
It is defined piecewise over the following productions:
The syntax-directed operation
The syntax-directed operation
本节由附录
The abstract operation ForIn/OfHeadEvaluation takes arguments uninitializedBoundNames (字符串列表), expr (
The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It performs the following steps when called:
The abstract operation EnumerateObjectProperties takes argument O (一个 Object) and returns 一个迭代器对象. It performs the following steps when called:
迭代器的 throw 与 return 方法为 next 决定是否返回一个
另外,若 O 及其原型链均非 Proxy /
实现无需直接实现
下列生成器函数是符合规则的示例:
function* EnumerateObjectProperties(obj) {
const visited = new Set();
for (const key of Reflect.ownKeys(obj)) {
if (typeof key === "symbol") continue;
const desc = Reflect.getOwnPropertyDescriptor(obj, key);
if (desc) {
visited.add(key);
if (desc.enumerable) yield key;
}
}
const proto = Reflect.getPrototypeOf(obj);
if (proto === null) return;
for (const protoKey of EnumerateObjectProperties(proto)) {
if (!visited.has(protoKey)) yield protoKey;
}
}
For-In Iterator 表示对特定对象的一次具体迭代,不能被脚本直接访问,仅用于描述
The abstract operation CreateForInIterator takes argument object (一个 Object) and returns 一个
%ForInIteratorPrototype% 对象:
实例为
| 内部槽 | 类型 | 描述 |
|---|---|---|
| [[Object]] | Object | 被 |
| [[ObjectWasVisited]] | Boolean | 若已在 [[Object]] 上调用 [[OwnPropertyKeys]] 则 |
| [[VisitedKeys]] | 字符串列表 | 迄今已发出的键。 |
| [[RemainingKeys]] | 字符串列表 | 当前对象剩余未发出的键(在遍历原型链之前)。 |
continue 语句 (The continue Statement)static 初始化块)嵌套于 break 语句 (The break Statement)static 初始化块)嵌套于 return 语句 (The return Statement)return 语句使函数终止执行并(大多数情况下)向调用者返回值;若省略 try/finally)中,返回值可能被之后的
with 语句 (The with Statement)with 语句把对象环境记录加入当前词法环境,然后使用扩展环境执行语句,结束后恢复原环境。
仅在实现
无论
switch 语句 (The switch Statement)若
The syntax-directed operation
The abstract operation CaseClauseIsSelected takes arguments C (
该操作不执行 C 的
无论控制如何离开
break / continue;语言无 goto。标签递归嵌套形成“当前标签集合”。
The abstract operation
The syntax-directed operation
throw 语句 (The throw Statement)try 语句 (The try Statement)try 语句封装可能发生异常的代码块;catch 提供处理逻辑;被捕获异常绑定到
The syntax-directed operation
无论
debugger 语句 (The debugger Statement)求值