[size=medium]The with statement is used to temporarily modify the scope
chain. It has the following syntax:
This statement effectively adds object to the front of the scope chain, executes statement , and then
restores the scope chain to its original state.
Despite its occasional convenience, use of the with statement is frowned upon. JavaScript code that uses
with is difficult to optimize and may therefore run more slowly than the equivalent code written without
the with statement. Furthermore, function definitions and variable initializations within the body of a with
statement can have surprising and counterintuitive behavior. For these reasons, it is recommended
that you avoid the with statement.[/size]
chain. It has the following syntax:
with (object) statement
This statement effectively adds object to the front of the scope chain, executes statement , and then
restores the scope chain to its original state.
Despite its occasional convenience, use of the with statement is frowned upon. JavaScript code that uses
with is difficult to optimize and may therefore run more slowly than the equivalent code written without
the with statement. Furthermore, function definitions and variable initializations within the body of a with
statement can have surprising and counterintuitive behavior.
发表评论
-
Extending Built-in Types
2009-01-08 13:55 725The Function.apply( ) method is ... -
Breakpoints using closures
2009-01-07 13:43 869// // This function implements ... -
Private properties with closures
2009-01-07 13:13 760// // This function adds proper ... -
Constructor Functions
2009-01-07 00:42 760the new operator creates a new ... -
Functions as Methods
2009-01-07 00:39 805When a function is invoked as a ... -
The callee Property
2009-01-07 00:02 664In addition to its array elemen ... -
Variable-Length Argument Lists: The Arguments Obje
2009-01-06 23:06 787The Arguments object has one ve ... -
Function Literals
2009-01-06 21:50 702Although function literals crea ... -
Nested Functions
2009-01-06 21:09 767Nested functions may be defined ... -
Deleting Array Elements
2009-01-05 22:11 567The delete operator sets an arr ... -
Reading and Writing Array Elements
2009-01-05 22:00 763Note that array indexes must be ... -
The valueOf() Method
2009-01-05 18:05 742... -
The toLocaleString() Method
2009-01-05 18:02 851In ECMAScript v3 and JavaScript ... -
The constructor Property
2009-01-05 17:51 789[size=medium]Since constructor ... -
the empty statement
2009-01-05 00:29 786[size=medium]When you intention ... -
try/catch/finnaly
2009-01-05 00:17 892If control leaves the try bloc ... -
throw
2009-01-04 23:56 693The tHRow statement has the fol ... -
return
2009-01-04 23:52 817If a function executes a return ... -
functions
2009-01-04 23:48 791[size=medium]Technically speaki ... -
Labels
2009-01-04 23:01 708Label names are distinct from v ...
评论