|
September 26, 1999 Avoid Repeating Object References Tips: September 1999
Yehuda Shiran, Ph.D.
|
|
JavaScript is an object-based language. Heavily object-dependent statements are often hard to read and understand, but JavaScript's with operator can simplify your statements. The general syntax of this construction is:
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:
People who read this tip also read these tips: Look for similar tips by subject: |