?um/p1-90`如果
无论控制如何离开
eval 函数的调用都会返回值 1:
eval("1;;;;;")
eval("1;{}")
eval("1;var a;")
The abstract operation BlockDeclarationInstantiation takes arguments code (a
当求值
它在被调用时执行以下步骤:
let、const、using 和 await using 声明定义的变量,其作用域为运行中执行上下文的 LexicalEnvironment。这些变量会在其let 声明中的
在处理产生式
的实例时,
The syntax-directed operation BindingEvaluation takes argument kind (
一条const、using 或 await using 声明中。
var 语句声明的变量,其作用域限定在运行中的执行上下文的 VariableEnvironment 内。var 变量会在其所在
如果
The syntax-directed operation PropertyBindingInitialization takes arguments value (an ECMAScript language value) and envRecord (an
The syntax-directed operation RestBindingInitialization takes arguments value (an ECMAScript language value), envRecord (an
The syntax-directed operation KeyedBindingInitialization takes arguments value (an ECMAScript language value), envRecord (an
It is defined piecewise over the following productions:
function 或 class async function 开始,因为这会使它与 let [ 开始,因为这会使它与首个 let
if 语句else] 以通常方式解决经典的“悬挂 else”问题。也就是说,当关联哪个 if 的选择除此之外存在歧义时,else 会与候选 if 中最近的(最内层的)那个关联只有在实现了
The abstract operation LoopContinues takes arguments completion (a
在
The syntax-directed operation LoopEvaluation takes argument labelSet (a
do-while 语句只有在实现了
The syntax-directed operation DoWhileLoopEvaluation takes argument labelSet (a
while 语句只有在实现了
The syntax-directed operation WhileLoopEvaluation takes argument labelSet (a
for 语句只有在实现了
The syntax-directed operation ForLoopEvaluation takes argument labelSet (a
The abstract operation ForBodyEvaluation takes arguments test (an
The abstract operation CreatePerIterationEnvironment takes argument perIterationBindings (a
for-in、for-of 和 for-await-of 语句本节由附录
只有在实现了
The syntax-directed operation IsDestructuring takes no arguments and returns a Boolean. It is defined piecewise over the following productions:
本节由附录
The syntax-directed operation ForDeclarationBindingInitialization takes arguments value (an ECMAScript language value) and envRecord (an
The syntax-directed operation ForDeclarationBindingInstantiation takes argument envRecord (a
The syntax-directed operation ForInOfLoopEvaluation takes argument labelSet (a
本节由附录
The abstract operation ForIn/OfHeadEvaluation takes arguments uninitializedBoundNames (a
The abstract operation ForIn/OfBodyEvaluation takes arguments lhs (a
The abstract operation EnumerateObjectProperties takes argument obj (an Object) and returns an
next 方法会遍历 obj 的可枚举属性中所有 String 值键。该迭代器对象永远不能被 ECMAScript 代码直接访问。枚举属性的机制和顺序未指定,但必须符合下面指定的规则。该迭代器的 throw 和 return 方法是 next 方法会处理对象属性,以确定是否应将next 方法处理某个属性之前被删除的属性会被忽略。如果在枚举期间向目标对象添加新属性,则不保证新添加的属性会在活动枚举中被处理。在任意枚举中,一个next 方法返回一次。
枚举目标对象的属性包括递归地枚举其原型、原型的原型,依此类推;但如果某个原型的属性与迭代器的 next 方法已经处理过的属性同名,则不会处理该原型属性。在确定原型对象的某个属性是否已经被处理过时,不考虑 [[Enumerable]] 特性的值。原型对象的可枚举
此外,如果 obj 及其原型链中的任何对象都不是
ECMAScript 实现不要求直接实现
以下是一个符合这些规则的 ECMAScript 生成器函数的信息性定义:
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 是一个表示对某个特定对象进行某次特定迭代的对象。For-In Iterator 对象永远不能被 ECMAScript 代码直接访问;它们的存在只是为了说明
The abstract operation CreateForInIterator takes argument obj (an Object) and returns a
%ForInIteratorPrototype% 对象:
| 内部槽 | 类型 | 描述 |
|---|---|---|
| [[Object]] | Object | 其属性正被迭代的 Object 值。 |
| [[ObjectWasVisited]] | Boolean |
如果迭代器已在 [[Object]] 上调用 [[OwnPropertyKeys]],则为 |
| [[VisitedKeys]] |
Strings 的 |
此迭代器到目前为止已经发出的值。 |
| [[RemainingKeys]] |
Strings 的 |
在迭代其原型的属性(如果其原型不是 |
continue 语句static 初始化块边界),则为语法错误。
break 语句static 初始化块边界),则为语法错误。
return 语句return 语句会使函数停止执行,并且在大多数情况下向调用者返回一个值。如果省略 return 语句实际上可能不会向调用者返回值。例如,在 try 块中,return 语句的 finally 块期间被另一个
with 语句with 语句会把一个计算所得对象的
只有在实现了
无论控制如何离开嵌入的
switch 语句如果
The syntax-directed operation CaseBlockEvaluation takes argument input (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:
The abstract operation CaseClauseIsSelected takes arguments caseClauseNode (a
此操作不会执行 caseClauseNode 的
无论控制如何离开
break 和 continue 语句结合使用。ECMAScript 没有 goto 语句。一个
The abstract operation IsLabelledFunction takes argument stmt (a
The syntax-directed operation LabelledEvaluation takes argument labelSet (a
throw 语句try 语句try 语句包围一段代码块,其中可能发生异常条件,例如运行时错误或 throw 语句。catch 子句提供异常处理代码。当 catch 子句捕获异常时,其
The syntax-directed operation CatchClauseEvaluation takes argument thrownValue (an ECMAScript language value) and returns either a normal completion containing either an ECMAScript language value or
无论控制如何离开
debugger 语句求值