Possible Duplicate:
Are there legitimate uses for JavaScript’s “with” statement?
I recently discovered that in JavaScript, one can do something like the following:
with (document) {
write('foo');
body.scrollTop = x;
}
The down side of this is that each variable needs to be checked to see if it belongs to the document object, creating a significant overhead.
Alternatively, one could do something like this:
var d = document;
d.write('foo');
d.body.scrollTop = x;
Are there any situations where the use of the 'with' keyword is justified?