September 26, 1999 - Avoid Repeating Object References
September 26, 1999 Avoid Repeating Object References Tips: September 1999
Yehuda Shiran, Ph.D.
|
with
operator can simplify your statements. The general syntax of this construction is:
with (object) {
statements
}
When JavaScript encounters an otherwise-unknown identifier inside a with
statement, it tries to build a reference out of the object specified as its parameter and that unknown identifier. Take a look at the following demonstration:
with (document) {
write("There are " + forms.length + " in this document.<BR>");
writeln("This is a simple example.");
}