?
u
m
/
No matter how control leaves the
The value of a eval
function all return the value 1:
eval("1;;;;;")
eval("1;{}")
eval("1;var a;")
The abstract operation BlockDeclarationInstantiation takes arguments code (a
When a
It performs the following steps when called:
let
and const
declarations define variables that are scoped to the let
declaration does not have an
A const
declaration.
A var
statement declares variables that are scoped to the
If a
The syntax-directed operation PropertyBindingInitialization takes arguments value and environment and returns either a
The syntax-directed operation RestBindingInitialization takes arguments value, environment, and excludedNames and returns either a
The syntax-directed operation KeyedBindingInitialization takes arguments value, environment, and propertyName and returns either a
When
It is defined piecewise over the following productions:
An function
or class
async function
because that would make it ambiguous with an let [
because that would make it ambiguous with a let
if
Statementelse
] resolves the classic "dangling else" problem in the usual way. That is, when the choice of associated if
is otherwise ambiguous, the else
is associated with the nearest (innermost) of the candidate if
sIt is only necessary to apply this rule if the extension specified in
The abstract operation LoopContinues takes arguments completion and labelSet and returns a Boolean. It performs the following steps when called:
Within the
The syntax-directed operation LoopEvaluation takes argument labelSet and returns either a
do
-while
StatementIt is only necessary to apply this rule if the extension specified in
The syntax-directed operation DoWhileLoopEvaluation takes argument labelSet and returns either a
while
StatementIt is only necessary to apply this rule if the extension specified in
The syntax-directed operation WhileLoopEvaluation takes argument labelSet and returns either a
for
StatementIt is only necessary to apply this rule if the extension specified in
The syntax-directed operation ForLoopEvaluation takes argument labelSet and returns either a
The abstract operation ForBodyEvaluation takes arguments test, increment, stmt, perIterationBindings, and labelSet and returns either a
The abstract operation CreatePerIterationEnvironment takes argument perIterationBindings and returns either a
for
-in
, for
-of
, and for
-await
-of
StatementsThis section is extended by Annex
It is only necessary to apply this rule if the extension specified in
If
If
The syntax-directed operation IsDestructuring takes no arguments and returns a Boolean. It is defined piecewise over the following productions:
This section is extended by Annex
The syntax-directed operation ForDeclarationBindingInitialization takes arguments value and environment and returns either a
var
statements and the formal parameter lists of some
It is defined piecewise over the following productions:
The syntax-directed operation ForDeclarationBindingInstantiation takes argument environment and returns
The syntax-directed operation ForInOfLoopEvaluation takes argument labelSet and returns either a
This section is extended by Annex
The abstract operation ForIn/OfHeadEvaluation takes arguments uninitializedBoundNames, expr, and iterationKind (
The abstract operation ForIn/OfBodyEvaluation takes arguments lhs, stmt, iteratorRecord, iterationKind, lhsKind (
The abstract operation EnumerateObjectProperties takes argument O (an Object) and returns an Iterator. It performs the following steps when called:
next
method iterates over all the String-valued keys of enumerable properties of O. The iterator object is never directly accessible to ECMAScript code. The mechanics and order of enumerating the properties is not specified but must conform to the rules specified below.The iterator's throw
and return
methods are next
method processes object properties to determine whether the next
method is ignored. If new properties are added to the target object during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. A next
method at most once in any enumeration.
Enumerating the properties of the target object includes enumerating properties of its prototype, and the prototype of the prototype, and so on, recursively; but a property of a prototype is not processed if it has the same name as a property that has already been processed by the iterator's next
method. The values of [[Enumerable]] attributes are not considered when determining if a property of a prototype object has already been processed. The enumerable property names of prototype objects must be obtained by invoking EnumerateObjectProperties passing the prototype object as the argument. EnumerateObjectProperties must obtain the own
In addition, if neither O nor any object in its prototype chain is a
ECMAScript implementations are not required to implement the algorithm in
The following is an informative definition of an ECMAScript generator function that conforms to these rules:
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;
}
}
A For-In Iterator is an object that represents a specific iteration over some specific object. For-In Iterator objects are never directly accessible to ECMAScript code; they exist solely to illustrate the behaviour of
The abstract operation CreateForInIterator takes argument object (an Object) and returns a For-In Iterator. It is used to create a For-In Iterator object which iterates over the own and inherited enumerable string properties of object in a specific order. It performs the following steps when called:
The %ForInIteratorPrototype% object:
For-In Iterator instances are
Internal Slot | Type | Description |
---|---|---|
[[Object]] | an Object | The Object value whose properties are being iterated. |
[[ObjectWasVisited]] | a Boolean |
|
[[VisitedKeys]] |
a |
The values that have been emitted by this iterator thus far. |
[[RemainingKeys]] |
a |
The values remaining to be emitted for the current object, before iterating the properties of its prototype (if its prototype is not |
continue
Statementstatic
initialization block boundaries), within an break
Statementstatic
initialization block boundaries), within an return
StatementA return
statement causes a function to cease execution and, in most cases, returns a value to the caller. If return
statement may not actually return a value to the caller depending on surrounding context. For example, in a try
block, a return
statement's finally
block.
with
StatementUse of the with
statement is discouraged in new ECMAScript code. Consider alternatives that are permitted in both
The with
statement adds an
It is only necessary to apply the second rule if the extension specified in
No matter how control leaves the embedded
switch
StatementThe syntax-directed operation CaseBlockEvaluation takes argument input and returns either a
The abstract operation CaseClauseIsSelected takes arguments C (a
This operation does not execute C's
No matter how control leaves the
A break
and continue
statements. ECMAScript has no goto
statement. A
An alternative definition for this rule is provided in
The abstract operation IsLabelledFunction takes argument stmt and returns a Boolean. It performs the following steps when called:
The syntax-directed operation LabelledEvaluation takes argument labelSet and returns either a
A
The only two productions of
throw
Statementtry
StatementThe try
statement encloses a block of code in which an exceptional condition can occur, such as a runtime error or a throw
statement. The catch
clause provides the exception-handling code. When a catch clause catches an exception, its
An alternative
The syntax-directed operation CatchClauseEvaluation takes argument thrownValue and returns either a
No matter how control leaves the
debugger
StatementEvaluating a