14.11 The with
Statement
Use of the with
statement is discouraged in new ECMAScript code. Consider alternatives that are permitted in both
Syntax
The with
statement adds an
14.11.1 Static Semantics: Early Errors
-
It is a Syntax Error if the
source text matched by this production is contained instrict mode code . -
It is a Syntax Error if
IsLabelledFunction (Statement ) istrue .
It is only necessary to apply the second rule if the extension specified in
14.11.2 Runtime Semantics: Evaluation
- Let val be ?
Evaluation ofExpression . - Let obj be ?
ToObject (?GetValue (val)). - Let oldEnv be the
running execution context 's LexicalEnvironment. - Let newEnv be
NewObjectEnvironment (obj,true , oldEnv). - Set the
running execution context 's LexicalEnvironment to newEnv. - Let C be
Completion (Evaluation ofStatement ). - Set the
running execution context 's LexicalEnvironment to oldEnv. - Return ?
UpdateEmpty (C,undefined ).
No matter how control leaves the embedded