For those who haven't seen the statement yet, the with() statement in JavaScript allows an object to be pushed onto the scope chain.

In short the common reason for it to be useful is if you had something like and then instead of typing that over and over you could use something like with( { a; b; }.

Unfortunately nearly every example people show is a poor example of how to use it, and then Crockford went and published a classic "Considered Harmful"[2] article describing a single very bad example of how to use with(), why with() is bad because of that one poor use, and as a result most people's opinion about with() is that the statement is evil "cause Crockford said so" without even thinking of good uses for the feature.

[Read more...]