STATEMENT: with
with
The with statement establishes a default object for a set of
statements. If there are any unqualified names in a set of
statements, JavaScript first checks the default object to see
if they exist there as properties of that object; otherwise a local
or global variable is used.
In the following example the default
object is 'beer' and the code displays one of two messages
depending on the value of the property 'percent_proof':
Code:
with(beer)
{
if(percent_proof < 5)
document.write("Call this a strong beer?!");
else
document.write("This is what I call a beer!");
}
|