The value of aStatementList is the value of the last value-producing item in theStatementList. For example, the following calls to theeval function all return the value 1:
eval("1;;;;;")eval("1;{}")eval("1;var a;")
14.2.3 BlockDeclarationInstantiation (code,env )
The abstract operation BlockDeclarationInstantiation takes argumentscode (aParse Node) andenv (aDeclarative Environment Record) and returnsunused.code is theParse Node corresponding to the body of the block.env is theEnvironment Record in which bindings are to be created.
Whenundefined is passed forenvironment it indicates that aPutValue operation should be used to assign the initialization value. This is the case for formal parameter lists ofnon-strict functions. In that case the formal parameter bindings are preinitialized in order to deal with the possibility of multiple parameters with the same name.
It is defined piecewise over the following productions:
The lookahead-restriction [lookahead ≠else] resolves the classic "dangling else" problem in the usual way. That is, when the choice of associatedif is otherwise ambiguous, theelse is associated with the nearest (innermost) of the candidateifs
The abstract operation LoopContinues takes argumentscompletion (aCompletion Record) andlabelSet (aList of Strings) and returns a Boolean. It performs the following steps when called:
The abstract operation CreatePerIterationEnvironment takes argumentperIterationBindings (aList of Strings) and returns either anormal completion containingunused or athrow completion. It performs the following steps when called:
undefined is passed forenvironment to indicate that aPutValue operation should be used to assign the initialization value. This is the case forvar statements and the formal parameter lists of somenon-strict functions (see10.2.11). In those cases a lexical binding is hoisted and preinitialized prior to evaluation of its initializer.
It is defined piecewise over the following productions:
The abstract operation EnumerateObjectProperties takes argumentO (an Object) and returns aniterator object. It performs the following steps when called:
Return aniterator object whosenext method iterates over all the String-valued keys of enumerable properties ofO. Theiterator 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.
Theiterator'sthrow andreturn methods arenull and are never invoked. Theiterator'snext method processes object properties to determine whether theproperty key should be returned as aniterator value. Returnedproperty keys do not include keys that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is processed by theiterator'snext 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. Aproperty name will be returned by theiterator'snext 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 theiterator'snext method. The values of[[Enumerable]] attributes are not considered when determining if a property of a prototype object has already been processed. The enumerableproperty names of prototype objects must be obtained by invoking EnumerateObjectProperties passing the prototype object as the argument. EnumerateObjectProperties must obtain the ownproperty keys of the target object by calling its[[OwnPropertyKeys]] internal method. Property attributes of the target object must be obtained by calling its[[GetOwnProperty]] internal method.
the value of the[[Prototype]] internal slot ofO or an object in its prototype chain changes,
a property is removed fromO or an object in its prototype chain,
a property is added to an object inO's prototype chain, or
the value of the[[Enumerable]] attribute of a property ofO or an object in its prototype chain changes.
Note 1
ECMAScript implementations are not required to implement the algorithm in14.7.5.10.2.1 directly. They may choose any implementation whose behaviour will not deviate from that algorithm unless one of the constraints in the previous paragraph is violated.
The following is an informative definition of an ECMAScript generator function that conforms to these rules:
The list ofexotic objects for which implementations are not required to matchCreateForInIterator was chosen because implementations historically differed in behaviour for those cases, and agreed in all others.
14.7.5.10 For-In Iterator Objects
AFor-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 ofEnumerateObjectProperties.
14.7.5.10.1 CreateForInIterator (object )
The abstract operation CreateForInIterator takes argumentobject (an Object) and returns aFor-In Iterator. It is used to create aFor-In Iterator object which iterates over the own and inherited enumerable string properties ofobject in a specific order. It performs the following steps when called:
It is a Syntax Error if thisContinueStatement is not nested, directly or indirectly (but not crossing function orstatic initialization block boundaries), within anIterationStatement.
It is a Syntax Error if thisBreakStatement is not nested, directly or indirectly (but not crossing function orstatic initialization block boundaries), within anIterationStatement or aSwitchStatement.
Areturn statement causes a function to cease execution and, in most cases, returns a value to the caller. IfExpression is omitted, the return value isundefined. Otherwise, the return value is the value ofExpression. Areturn statement may not actually return a value to the caller depending on surrounding context. For example, in atry block, areturn statement'sCompletion Record may be replaced with anotherCompletion Record during evaluation of thefinally block.
Thewith statement adds anObject Environment Record for a computed object to the lexical environment of therunning execution context. It then executes a statement using this augmented lexical environment. Finally, it restores the original lexical environment.
No matter how control leaves the embeddedStatement, whether normally or by some form ofabrupt completion or exception, the LexicalEnvironment is always restored to its former state.
This operation does not executeC'sStatementList (if any). TheCaseBlock algorithm uses its return value to determine whichStatementList to start executing.
AStatement may be prefixed by a label. Labelled statements are only used in conjunction with labelledbreak andcontinue statements. ECMAScript has nogoto statement. AStatement can be part of aLabelledStatement, which itself can be part of aLabelledStatement, and so on. The labels introduced this way are collectively referred to as the “current label set” when describing the semantics of individual statements.
The abstract operation IsLabelledFunction takes argumentstmt (aStatementParse Node) and returns a Boolean. It performs the following steps when called:
Thetry statement encloses a block of code in which an exceptional condition can occur, such as a runtime error or athrow statement. Thecatch clause provides the exception-handling code. When a catch clause catches an exception, itsCatchParameter is bound to that exception.
Evaluating aDebuggerStatement may allow an implementation to cause a breakpoint when run under a debugger. If a debugger is not present or active this statement has no observable effect.