"with" keyword in javascript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/61552/are-there-legitimate-uses-for-javascripts-with-statement">Are there legitimate uses for JavaScript&rsquo;s &ldquo;with&rdquo; statement?</a>  </p>
</blockquote>

<p>I recently discovered that in javascript, one can do something like the following:</p>

<pre><code>with document{
    write('foo');
    body.scrollTop = x;
}
</code></pre>

<p>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.</p>

<p>Alternatively, one could do something like this:</p>

<pre><code>var d = document;
d.write('foo');
d.body.scrollTop = x;
</code></pre>

<p>Are there any situations where the use of the 'with' keyword is justified?</p>
